How do I make @CommitAfter work outside of a normal web request? (By way of background, I have a web app that also receives messages that require database work via JGroups. These aren't web requests, but I want to use the same hibernate configuration and infrastructure if at all possible.)
Right now the basic code looks like this: // The service that listens to incoming JGroups messages public class MyReceiverServiceImpl extends /*JGroups*/ReceiverAdapter { @Inject private PerthreadManager threadManager; @Inject private PeerMessageProcessor messageProcessor; @Override public void receive(final Message message) { threadManager.run(new Runnable() { @Override public void run() { messageProcessor.receive(message); } }); } // The service that tries to save the serialized entities via tapestry-hibernate public class PeerMessageProcessorImpl implements PeerMessageProcessor { @Inject private Session session; @CommitAfter public void receive(Message message) { Object payload = message.getObject(); session.save(payload); } Unfortunately, the transaction is never committed. As far as I know: 1. The CommitAfter advisor does advise my service methods (but I'm not sure how to verify this). 2. My methods are properly invoked (which I've verified) It feels like this should be straight forward! Gratefully, Michael