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 {
ExecutorService executorService;
private InjectManager _webBeans = InjectManager.create();

public void onMessage(Message message) {
 RealStuffRunnable runnable = webBeans.getReference(RealStuffRunnable
 // set some properties of runnable
 // run it in a new thread

3. Use @TransactionAttribute on

Thus my real stuff will not suffer from the reenter and crossing commit.

Any better solutions?

resin-interest mailing list

Reply via email to