Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events: Transactional Observers #15

Open
hendryluk opened this issue Feb 10, 2015 · 0 comments
Open

Events: Transactional Observers #15

hendryluk opened this issue Feb 10, 2015 · 0 comments

Comments

@hendryluk
Copy link
Owner

Expanding on #7

CDI spec allows you to specify that a particular observer should receive event notifications during the before or after completion phase of the transaction in which the event was raised. I.e. it defers the notifications of an event until the intended phase of the transaction has been reached (as opposed to the current implementation that only allows immediate notifications).
Ref: https://docs.jboss.org/weld/reference/latest/en-US/html/events.html#_transactional_observers

Supported options are:

  • IN_PROGRESS
  • AFTER_SUCCESS
  • AFTER_FAILURE
  • AFTER_COMPLETION
  • BEFORE_COMPLETION

Example

public void OnLoggedIn([Observes(During=TransactionPhase.AfterSuccess)] LoggedIn evt)
{
   /* handles */
}

This is important e.g. in scenario where you want to send an outbound customer email only after the transaction has been successfully committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant