Announcement Announcement Module
Collapse
No announcement yet.
Committing JDBC and JMS resources together... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Committing JDBC and JMS resources together...

    I will be deploying my application most likely on IBM WebSphere 6.1 - business requirements dictate that in some instances I'll need to persist data to a DB2 database and drop a message into a JMS queue... Would like to commit both operations under Transaction control, so it's either both or none - is that possible on WebSphere 6.1 out of the box? I recall some special considerations for DB and JMS together... If it's possible, what TransactionManager should I be using to do this - anything special?

    I should mention that WebSphere MQ 6.0 is the messaging infrastructure.

    James

  • #2
    Yes, this is definitely possible: just use the JtaTransactionManager, since you'll be needing 2 phase commit support. Also make sure that you use the XA-capable version of the DB2 drivers.

    This is assuming that you do not need transaction suspension support (PROPAGATION_REQUIRES_NEW / PROPAGATION_NOT_SUPPORTED). If you do, then you'll also need to configure a WebSphereTransactionManagerFactoryBean for the JtaTransactionManager, assuming you're using Spring 2.0.
    If you are already using a Spring 2.1 milestone, be sure to use the new WebSphereUowTransactionManager instead of the regular JtaTransactionManager: this allows full integration with WebSphere's transaction manager in an IBM-supported fashion.

    OTOH, you're posting in the EJB-forum, so are you using Spring's transaction support or EJB CMT? If Spring's tx mgt, then I suggest that you use the Data Access forum instead to pose these sort of questions; your chances of getting an answer are greater there. If you're using EJB CMT, then please be aware of the fact that you can't look up the UserTransaction inside of a CMT transaction in WebSphere: therefore, you'll need to tell Spring not to try, like this:

    Code:
    <!--  This transaction manager will cooperate with the CMT-initiated JTA transactions -->
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <!-- Since we participate in a CMT transaction, we may not look up the UserTransaction; see the following page for an explanaton:
             http://publib.boulder.ibm.com/infocenter/wasinfo/v5r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/cjta_glotran.html
          -->
        <property name="userTransactionName"><null /></property>
    </bean>
    If you're also using a WebSphereTransactionManager, set the transactionManager property of the JtaTransactionManager by refering to it or declaring it as an inline bean:

    Code:
    ...
        <property name="transactionManager" ref="wasTransactionManager"/>
    </bean>
    
    <bean id="wasTransactionManager" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/>

    Comment

    Working...
    X