Announcement Announcement Module
Collapse
No announcement yet.
Spring batch with MDB Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


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

            Comment


            • #7
              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.

              Comment


              • #8
                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.

                Comment


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

                  Comment


                  • #10
                    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

                    Comment


                    • #11
                      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

                      Comment

                      Working...
                      X