More to mention about MDBs (Message Driven Beans):
1. Always use @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
on public void onMessage(Message message).
because the impl of Resin MDBs has severe reenter synchronization problem.
If I start a transaction before onMessage() being called there would be
several transactions tried to crossing commit in unexpected manner.
2. Inject a ExecutorService to do the real stuff.
public class MyMessageDrivenBean implements MessageListener {
@Inject
ExecutorService executorService;
private InjectManager _webBeans = InjectManager.create();
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void onMessage(Message message) {
RealStuffRunnable runnable = webBeans.getReference(RealStuffRunnable
.class);
// set some properties of runnable
...
// run it in a new thread
executorService.execute(runnable);
}
}
3. Use @TransactionAttribute on RealStuffRunnable.run()
Thus my real stuff will not suffer from the reenter and crossing commit.
Any better solutions?
-Wesley
_______________________________________________
resin-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/resin-interest