MDB getting triggered before global transaction on client co
rsait Nov 20, 2002 10:57 AMI have a client that posts a message to JMS Queue and write a database record about the message in a global transaction by calling a method on stateless session bean.
Associated with JMS Queue, I have a MDB registered to process the messages. In the OnMessage Handler I tried to update the database record with some status and proceed to process the message.
The trans-attr on stateless session bean method is Required. The stateless session bean uses XAConnectionFactory and OracleXA classes to participate in global txn.
I am seeing the message driven bean is invoked before the global transaction is commited to the database. As a result the database record is created after the MDB is invoked which results in some of the updates not happening in the database
Enclosed is my ejb-jar
------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<!-- Copyright 2002 Sun Microsystems, Inc. All rights reserved. -->
<ejb-jar>
<display-name>CTRDemoMDBJAR</display-name>
<enterprise-beans>
<message-driven>
<display-name>CTRDemoMDB</display-name>
<ejb-name>CTRMsgProcessEJB</ejb-name>
<ejb-class>com.putnam.ctr.demo.ejb.PAHPMessageBean</ejb-class>
<transaction-type>Bean</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<ejb-ref>
<ejb-ref-name>ejb/PACalcRequest</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.putnam.ctr.demo.ejb.PACalcRequestHome</home>
<remote>com.putnam.ctr.demo.ejb.PACalcRequest</remote>
</ejb-ref>
<resource-ref>
<description></description>
<res-ref-name>jdbc/OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<res-ref-name>jms/PAHPConnectionFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
<session>
<description>This session bean implements a session to post
a Calculation Request to High and Low priority message queues
</description>
<ejb-name>PACalcRequest</ejb-name>
<home>com.putnam.ctr.demo.ejb.PACalcRequestHome</home>
<remote>com.putnam.ctr.demo.ejb.PACalcRequest</remote>
<ejb-class>com.putnam.ctr.demo.ejb.PACalcRequestBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<security-identity>
<description></description>
<use-caller-identity></use-caller-identity>
</security-identity>
<resource-ref>
<res-ref-name>jms/PAHPQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/PAHPConnectionFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description></description>
<res-ref-name>jdbc/XAOracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>CTRMsgProcessEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>onMessage</method-name>
<method-params>
<method-param>javax.jms.Message</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>PACalcRequest</ejb-name>
<method-intf>Remote</method-intf>
<method-name>submitComputeRequest</method-name>
<method-params>
<method-param>String</method-param>
<method-param>String</method-param>
<method-param>String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>PACalcRequest</ejb-name>
<method-intf>Remote</method-intf>
<method-name>submitRevisionRequest</method-name>
<method-params>
<method-param>String</method-param>
<method-param>String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
------
I am using JBOSS 3.0.2 version. Any ideas if this is a bug or something that I am doing wrong.
Thanks in advance
Raja Sait