Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Spring batch with MDB

  1. #1

    Default Spring batch with MDB

    I'm trying to deploy spring batch application into websphere along with
    MessageDriveBean(BatchListenerBean.java,E.J.B Component).
    My intention is to keep the job file, in mq, so that mdb will automatically consume the file as a message, and invoke springbatch application.
    does this design works? Though it is pretty standard way, I'm little bit doubtful, on compatibility of MDB(E.J.B Component) invoking spring batch application.
    Moreover, while I'm trying to deploy the entire application, into websphere, I'm gettting the following exception.
    Code:
    5/28/09 11:22:55:092 CDT] 00000015 SystemOut     O com.ibm.ws.exception.RuntimeError: java.lang.UnsatisfiedLinkError: mqjbnd05 (Not found in java.library.path)
    Any suggestions?
    Thanks

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    There's nothing wrong with launching a job from an MDB. Just make sure that you disable container managed transactions, otherwise your whole job will be wrapped in a transaction by the container.

    The error you pasted looks unrelated to batch concerns. Appears to be a configuration problem for your container.

  3. #3

    Default

    Thanks.
    This part is working fine now. But I have one more issue.

    Currently I hardcoded userid and password of db2 in the configuration file.
    But our DBA Wanted to configure datasource of websphere, and get connected to db2 from application using datasource.
    What are the modifications I need to do to meet this requirement?
    I appreciate your response.
    More over, just want to clarify, whether I get any negative results, if I use websphere transaction management,instead of spring batch.
    Thanks
    Krishna

  4. #4
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Getting access to the datasource of Websphere is pretty straightforward, since it's just a JNDI resource. Read the official Spring reference documentation on how to access JNDI resources within your application context.

    There's nothing wrong with using Websphere's transaction manager, you'll just need to use the Spring JtaTransactionManager. (More details are in the reference docs) What you can't do, is let Websphere manage the transaction. Under the covers Spring Batch will use a UserTransaction, so that we can control commit points.

  5. #5

    Default

    I used JTA Transaction manager as suggested.
    Code:
    <!-- DataSource Definition -->
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        		<property name="jndiName" value="jdbc/itemsub/db2"/>
        </bean>
     <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
       			<property name="transactionManager" ><bean class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/></property>
    </bean>
    Soon after I trigger mdb by passing message into mq, spring batch is getting executed, and at end I'm getting folloiwng exception and listener port is getting stopped.

    Code:
    [6/8/09 17:40:41:099 CDT] 0000001e ServerSession W   WMSG0031E: Exception processing JMS Message for
    MDB BatchListener, JMSDestination jms/itemsub/batchQ : javax.ejb.TransactionRolledbackLocalException:  ; nested exception is: com.ibm.websphere.csi.CSITransactionRolledbackException: 
    com.ibm.websphere.csi.CSITransactionRolledbackException: 
    	at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:769)
    	at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:181)
    	at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:581)
    	at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3876)
    	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:107)
    	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:132)
    	at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:481)
    	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
    javax.ejb.TransactionRolledbackLocalException:  ; nested exception is: com.ibm.websphere.csi.CSITransactionRolledbackException: 
    	at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:769)
    	at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:181)
    	at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:581)
    	at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3876)
    	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:107)
    	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:132)
    	at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:481)
    	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
    Caused by: com.ibm.websphere.csi.CSITransactionRolledbackException: 
    	... 8 more
    
    [6/8/09 17:40:41:114 CDT] 0000001e ServerSession W   WMSG0036E: Maximum message delivery retry count of 0 reached for MDB BatchListener, JMSDestination jms/itemsub/batchQ, MDBListener stopped
    [6/8/09 17:40:40:833 CDT] 0000001e SystemErr     R 221  
    [6/8/09 17:40:44:880 CDT] 00000031 MDBListenerIm I   WMSG0043I: MDB Listener itemsubListenerPort stopped for JMSDestination jms/itemsub/batchQ
    Its appearing like there is some conflict at commiting the transaction, and websphere trying to roleback the uncommited transaction and hence throwing the error.
    In fact there are no excptions coming from spring batch.
    Please suggest.
    Thanks

  6. #6
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Did you make sure again that CMT are switched off for your MDB?

  7. #7

    Default

    How to switch off Container Managed Transactictions for MDB?
    I did n't find a way to do this. Any suggestions? My apologies if this issue is out of spring batch scope.

  8. #8
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    It should be in the deployment descriptor (ejb.xml or whatever it is called on your platform). If you use an IDE to create the JAR/EAR it probably has a little checkbox you can click on.

  9. #9

    Default

    I changed the Transaction Type of ejb deployment descriptor from container to bean, and it fixed the issue.
    Thanks

  10. #10
    Join Date
    Oct 2011
    Posts
    2

    Default

    Rajashekar,

    Can you please post me the complete XML file as I am using the same sort of application.

    Where you configure the spring config and MDB together ?

    How you run ?

    Please give me more details if you can
    thanks
    sunil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •