1

Is there something in EJB3 that allows me to execute some code just after the transaction commit (I want to send XMPP messages to notify external devices for updates) ?

I know I can do something like that using JTA API and enlisting my own writed XA resource but I have the feeling that's it's not the right tool.

Thx

Brett Kail
  • 33,593
  • 2
  • 85
  • 90
Jonathan
  • 13
  • 3

1 Answers1

3

Create a stateful session bean that implements javax.ejb.SessionSynchronization, and call a method from within the transaction. The afterCompletion method will be called with the outcome of the transaction.

Update: if you're using EJB 3.1, you can annotate a method of the SFSB with @AfterCompletion rather than implementing the interface.

Brett Kail
  • 33,593
  • 2
  • 85
  • 90