This discussion is archived
2 Replies Latest reply: Dec 22, 2011 6:47 AM by 744235 RSS

reg MDB transaction rollback

744235 Newbie
Currently Being Moderated
i have an MDB deployed on weblogic 8.1 sp6 server. My confusion here is how the MDB handles transaction rollbacks. E.g suppose if the MDB is designed to do the below action.

1) read an xml message from a jms queue
2) insert some database records
3) generate some xml message, post it to some other jms queue

suppose if step 1 and 2 is completed, and its on step 3, at this point weblogic server shutdowns suddenly, once i restart the server, it reads the xml message again from the jms queue, but this time it errors out, because it finds the data already entered in step 2.

My question is when the weblogic server shut down while the mdb was at step 3, why didnt it removed all the db entries it made in step 2. This behaviour apears to me as partial rollback. I have given the mdb descriptor below.
<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <ejb-name>CSS_Response</ejb-name>
      <ejb-class>com.bt.neo.core.utility.appcontroller.transport.mdb.JmsMessageReceiver</ejb-class>
      <transaction-type>Container</transaction-type>
      <acknowledge-mode>auto-acknowledge</acknowledge-mode>
      <message-driven-destination>
        <destination-type>javax.jms.Queue</destination-type>
      </message-driven-destination>

      <env-entry>
        <env-entry-name>ejb/BeanFactoryPath</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>core-css-response-inbound.xml</env-entry-value>
      </env-entry>
      <env-entry>
        <env-entry-name>ProcessorBeanName</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>transportAdaptor</env-entry-value>
      </env-entry>
      <resource-ref>
        <res-ref-name>jms/faultTo</res-ref-name>
        <res-type>javax.jms.Destination</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>
    </message-driven>
  </enterprise-beans>

  <assembly-descriptor>
    <container-transaction>
      <method>
        <ejb-name>CSS_Response</ejb-name>
        <method-name>onMessage</method-name>
        <method-params>
          <method-param>javax.jms.Message</method-param>
        </method-params>

      </method>
      <trans-attribute>Required</trans-attribute>
    </container-transaction>
  </assembly-descriptor>

</ejb-jar>
Please clear my doubt.

Edited by: Deepak Dev on 19-Dec-2011 11:01
  • 1. Re: reg MDB transaction rollback
    RenévanWijk Oracle ACE
    Currently Being Moderated
    General information on message-driven beans can be found here: http://docs.oracle.com/cd/E12840_01/wls/docs103/ejb/message_beans.html

    To transaction configuration is discussed here: http://docs.oracle.com/cd/E12840_01/wls/docs103/ejb/message_beans.html#wp1162058

    Looks like you have to set the transaction-type to Container and the trans-attribute to required. Also see the note:
    - However, if you make this configuration error, the MDB will not run transactionally—if a failure occurs mid-transaction, updates that occurred prior to the failure will not be rolled back.
  • 2. Re: reg MDB transaction rollback
    744235 Newbie
    Currently Being Moderated
    the ejb already has the set transaction type set as container
    <transaction-type>Container</transaction-type>

    and the transaction attribute set as required
    <trans-attribute>Required</trans-attribute>

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points