Acknowledging Messages from Message-Driven Beans

   

Using Transactions with Message-Driven Beans

As with session beans, message-driven beans can use either bean-managed transactions or container-managed transactions. Because a client has no way to call the message-driven bean directly, the client can't propagate its transaction context to the message-driven bean. The container will always call the onMessage method with a transaction context that is specified in the bean's deployment descriptor.

Therefore, a message-driven bean that is using container-managed transaction should specify either the Required or NotSupported transaction attribute in the ejb-jar.xml file. This is because if the message-driven bean needs a transaction, the container will have to create one before calling the onMessage method, because there's no chance to propagate a transaction from the client. If the message-driven bean doesn't need a transaction, you should specify the NotSupported transaction attribute.

For more information on transactions, see Chapter 12, "Transactions."



Special Edition Using Enterprise JavaBeans 2.0
Special Edition Using Enterprise JavaBeans 2.0
ISBN: 0789725673
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net