Announcement Announcement Module
Collapse
No announcement yet.
Transactions and Websphere MQ Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transactions and Websphere MQ

    Hi,

    I'm writting a standalone Java 1.4 application that communicates with a Websphere Application Server 5.1 installation on Windows 2003. Through my WAS I can lookup a queue connection factory and queues to a Websphere MQ installation located on the mainframe (z/OS).

    I cannot the transaction scope to work as intended. If an uncaught exception is thrown the outcome of the transaction rollback is not as I expect. The message is not put back on the queue.

    Below you have parts of my application context:

    Code:
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" >
    	<property name="autodetectTransactionManager" value="false" />
    	<property name="jndiTemplate">
    		<ref bean="jndiTemplate" />
    	</property>
    	<property name="userTransactionName" value="jta/usertransaction" />
    </bean>
    ....
    <!-- this is the Message Driven POJO (MDP) for processing messages ... -->
    <bean id="myMessageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter102">
    	<constructor-arg>
    		<bean class="dk.mycompany.MyMessageListener"/>
    	</constructor-arg>
    	<property name="defaultListenerMethod" value="onMessage" />
    	<!-- we don't want automatic message context extraction -->
    	<property name="messageConverter">
    		<null />
    	</property>
    </bean>
    
    <!-- ... and this is the associated message listener container -->
    <bean id="myMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer102">
    	<property name="concurrentConsumers">
    		<value>1</value>
    	</property>
    	<property name="connectionFactory" ref="mvsQueueConnectionFactory" />
    	<property name="destination" ref="fromMvsQueueDestination" />
    	<property name="messageListener" ref="myMessageListener" />
    	<property name="recoveryInterval">
    		<value>60000</value>
    	</property>
    	<property name="transactionManager" ref="transactionManager"/>
    </bean>
    I will post a reply to this message that includes a log trace of my program.

    In-house we have a standard J2EE application using Message Driven Beans with Container Managed Transaction and it works as intended. That tells me that there is no general problem in accessing Websphere MQ on z/OS from a Websphere Application Server on Windows 2003. However, that is done from the EJB container and my program is running outside the container. Maybe that can be the problem?

    Any help would be appreciated. Is there anything wrong with my application context? Anything in my logs that looks odd?

  • #2
    Log trace

    Log trace:

    Code:
    2007-11-02 10:44:32,578 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Retrieving JTA UserTransaction from JNDI location [jta/usertransaction]
    2007-11-02 10:44:32,594 CET INFO  [org.springframework.transaction.jta.JtaTransactionManager] - Using JTA UserTransaction: com.ibm.ws.Transaction.JTA.UserTransactionImpl@39e2334f
    2007-11-02 10:44:32,594 CET WARN  [org.springframework.transaction.jta.JtaTransactionManager] - No JTA TransactionManager found: transaction suspension and synchronization with existing JTA transactions not available
    2007-11-02 10:44:32,750 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Using transaction object [[email protected]]
    2007-11-02 10:44:32,766 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Creating new transaction with name [null]
    2007-11-02 10:44:32,766 CET DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Initializing transaction synchronization
    2007-11-02 10:44:32,922 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Using transaction object [[email protected]]
    2007-11-02 10:44:32,922 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Creating new transaction with name [null]
    2007-11-02 10:44:32,922 CET DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Initializing transaction synchronization
    2007-11-02 10:44:33,609 CET DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Bound value [org.springframework.jms.connection.JmsResourceHolder@6de4b34d] for key [com.ibm.mq.jms.MQXAQueueConnectionFactory@8f08dc97] to thread [myMessageListenerContainer-1]
    2007-11-02 10:44:33,609 CET DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Bound value [org.springframework.jms.connection.JmsResourceHolder@4a1ab34c] for key [com.ibm.mq.jms.MQXAQueueConnectionFactory@8f08dc97] to thread [myReprocessMessageListenerContainer-1]
    2007-11-02 10:44:33,688 CET DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer102] - Received message of type [class com.ibm.jms.JMSTextMessage] from consumer [com.ibm.mq.jms.MQQueueReceiver@35fc3343] of transactional session [com.ibm.mq.jms.MQQueueSession@5e28334d]
    2007-11-02 10:44:33,688 CET DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer102] - Invoking listener with message of type [class com.ibm.jms.JMSTextMessage] and session [com.ibm.mq.jms.MQQueueSession@5e28334d]
    2007-11-02 10:44:34,375 CET ERROR [dk.mycompany.MyMessageListener] - Failed to process message : msg=null
    java.lang.StringIndexOutOfBoundsException: String index out of range: -153
    	at java.lang.String.substring(String.java(Compiled Code))
    ...
    	at dk.mycompany.MyMessageListener.onMessage(MyMessageListener.java:51)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
    	at java.lang.reflect.Method.invoke(Method.java:391)
    	at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:270)
    	at org.springframework.jms.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:433)
    	at org.springframework.jms.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:335)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:833)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:794)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:767)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.doReceiveAndExecute(DefaultMessageListenerContainer.java:531)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.receiveAndExecute(DefaultMessageListenerContainer.java:459)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:889)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:842)
    	at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:203)
    	at java.lang.Thread.run(Thread.java:568)
    2007-11-02 10:44:34,438 CET DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Retrieved value [org.springframework.jms.connection.JmsResourceHolder@6de4b34d] for key [com.ibm.mq.jms.MQXAQueueConnectionFactory@8f08dc97] bound to thread [myMessageListenerContainer-1]
    2007-11-02 10:44:34,469 CET DEBUG [org.springframework.jms.core.JmsTemplate102] - Executing callback on JMS Session [com.ibm.mq.jms.MQQueueSession@5e28334d]
    2007-11-02 10:44:34,531 CET DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer102] - Rolling back transaction because of listener exception thrown: org.springframework.jms.listener.adapter.ListenerExecutionFailedException: Listener method 'onMessage' threw exception; nested exception is java.lang.IllegalStateException: Cannot invoke method 'toString' during simulation!
    2007-11-02 10:44:34,531 CET ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer102] - Execution of JMS message listener failed
    org.springframework.jms.listener.adapter.ListenerExecutionFailedException: Listener method 'onMessage' threw exception; nested exception is java.lang.IllegalStateException: Cannot invoke method 'toString' during simulation!
    Caused by: 
    java.lang.IllegalStateException: XXX
    ...
    	at $Proxy0.toString(Unknown Source)
    	at java.lang.String.valueOf(String.java:2506)
    	at java.lang.StringBuffer.append(StringBuffer.java:433)
    	at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:510)
    	at org.springframework.jms.core.JmsTemplate$2.doInJms(JmsTemplate.java:478)
    	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:429)
    	at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:476)
    	at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:557)
    ...
    	at dk.mycompany.MyMessageListener.onMessage(MyMessageListener.java:51)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
    	at java.lang.reflect.Method.invoke(Method.java:391)
    	at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:270)
    	at org.springframework.jms.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:433)
    	at org.springframework.jms.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:335)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:833)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:794)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:767)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.doReceiveAndExecute(DefaultMessageListenerContainer.java:531)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.receiveAndExecute(DefaultMessageListenerContainer.java:459)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:889)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:842)
    	at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:203)
    	at java.lang.Thread.run(Thread.java:568)
    2007-11-02 10:44:34,594 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Transactional code has requested rollback
    2007-11-02 10:44:34,594 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Triggering beforeCompletion synchronization
    2007-11-02 10:44:34,609 CET DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Removed value [org.springframework.jms.connection.JmsResourceHolder@6de4b34d] for key [com.ibm.mq.jms.MQXAQueueConnectionFactory@8f08dc97] from thread [myMessageListenerContainer-1]
    2007-11-02 10:44:34,625 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Initiating transaction rollback
    2007-11-02 10:44:34,625 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Triggering afterCompletion synchronization
    2007-11-02 10:44:34,625 CET DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] - Clearing transaction synchronization
    2007-11-02 10:44:34,625 CET DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Using transaction object [[email protected]]

    Comment


    • #3
      message driven adapter and XA rollback.

      I am facing the same issue in jboss/ jdk 1.5

      I dont see the message thrown back to the queue after XA rollback from message driven adapter.

      I used the last example from

      http://static.springframework.org/sp...ssageReception

      Comment


      • #4
        From your log file I see the following error:

        2007-11-02 10:44:32,594 CET WARN [org.springframework.transaction.jta.JtaTransaction Manager] - No JTA TransactionManager found: transaction suspension and synchronization with existing JTA transactions not available


        It looks like you haven't configured your transaction manager to use the actual Websphere transaction manager. Therefore your operation is never actually enlisted in a transaction it seems.

        This is how I have my transaction manager setup with WBISF (WAS 5.1.1)

        Code:
        <bean id="WASJtaTxMgr" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean" />
        
        <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        		<property name="userTransactionName"><null /></property>
        		<property name="transactionManager" ref="WASJtaTxMgr" />
        </bean>
        Here, the JTA transaction manager delegates to the underlying WAS transaction manager as wrapped by the Spring org.springframework.transaction.jta.WebSphereTrans actionManagerFactoryBean class.

        Also, we had to set userTransactionName to null as there is a known issue with WAS 5.1 not storing the transaction manager properly in JNDI.

        Try this and see if it helps.

        Comment


        • #5
          Originally posted by jwalsh View Post
          From your log file I see the following error:

          2007-11-02 10:44:32,594 CET WARN [org.springframework.transaction.jta.JtaTransaction Manager] - No JTA TransactionManager found: transaction suspension and synchronization with existing JTA transactions not available


          It looks like you haven't configured your transaction manager to use the actual Websphere transaction manager. Therefore your operation is never actually enlisted in a transaction it seems.
          No, this is not the problem. It's finding the UserTransaction okay but not the TransactionManager (which is only used for synchronization and suspension, which you don't need in this case). Also, jwalsh's configuration while it probably works is not officially supported by Websphere. This can get you into trouble, especially if you go to call them for support. (They look for every excuse they can to declare your code unsupported).

          For the record, your transaction manager definition should look like this:

          Code:
          <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" >
          	<property name="autodetectTransactionManager" value="false" />
          </bean>
          Anyways, my guess is that your problem is that you are using the default TaskExecutor implementation (i.e. SimpleAsyncTaskExecutor). This creates unmanaged threads on the server, which can certainly be an issue when you are accessing JNDI resources (such as JTA UserTransactions for instance).

          This IBM how-to is an absolute must read for anyone using Websphere and Spring. It will tell you everything you need to know about the dos and don'ts with WAS, including how to set up a WorkManagerTaskExecutor, which is what you need in this case:

          http://www.ibm.com/developerworks/we...09_alcott.html

          Comment


          • #6
            not work when I try WebSphereUowTransactionManager

            I use spring 2.5.6 + WAS 6.0.
            Should I upgrade WAS version???
            [2009/12/23 15:11:59:444 CST] 0000000a SystemErr R org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'NcdJtaDS' defined in ServletContext resource [/WEB-INF/applicationContext-jms.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name "comp/websphere/UOWManager" not found in context "java:".
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1338)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
            at java.security.AccessController.doPrivileged1(Nativ e Method)
            at java.security.AccessController.doPrivileged(Access Controller.java(Compiled Code))
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
            at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
            at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
            at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
            at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:423)
            at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:728)
            at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:380)
            at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:255)
            at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:199)
            at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 45)
            at com.ibm.ws.webcontainer.webapp.WebApp.notifyServle tContextCreated(WebApp.java:1355)
            at com.ibm.ws.webcontainer.webapp.WebApp.initialize(W ebApp.java:371)
            at com.ibm.ws.webcontainer.webapp.WebGroup.addWebAppl ication(WebGroup.java:114)
            at com.ibm.ws.webcontainer.VirtualHost.addWebApplicat ion(VirtualHost.java:127)
            at com.ibm.ws.webcontainer.WebContainer.addWebApp(Web Container.java:776)
            at com.ibm.ws.webcontainer.WebContainer.addWebApplica tion(WebContainer.java:729)
            at com.ibm.ws.runtime.component.WebContainerImpl.inst all(WebContainerImpl.java:140)
            at com.ibm.ws.runtime.component.WebContainerImpl.star t(WebContainerImpl.java:360)
            at com.ibm.ws.runtime.component.ApplicationMgrImpl.st art(ApplicationMgrImpl.java:1019)
            at com.ibm.ws.runtime.component.DeployedApplicationIm pl.fireDeployedObjectStart(DeployedApplicationImpl .java:1028)
            at com.ibm.ws.runtime.component.DeployedModuleImpl.st art(DeployedModuleImpl.java:538)
            at com.ibm.ws.runtime.component.DeployedApplicationIm pl.start(DeployedApplicationImpl.java:724)
            at com.ibm.ws.runtime.component.ApplicationMgrImpl.st artApplication(ApplicationMgrImpl.java:683)
            at com.ibm.ws.runtime.component.ApplicationMgrImpl$Ap pInitializer.run(ApplicationMgrImpl.java:1678)
            at com.ibm.ws.runtime.component.ComponentImpl.runAsyn chronousInitializer(ComponentImpl.java:159)
            at com.ibm.ws.runtime.component.ApplicationMgrImpl.st artApplications(ApplicationMgrImpl.java:545)
            at com.ibm.ws.runtime.component.ApplicationMgrImpl.st art(ApplicationMgrImpl.java:368)
            at com.ibm.ws.runtime.component.ContainerImpl.startCo mponents(ContainerImpl.java:821)
            at com.ibm.ws.runtime.component.ContainerImpl.start(C ontainerImpl.java:649)
            at com.ibm.ws.runtime.component.ApplicationServerImpl .start(ApplicationServerImpl.java:149)
            at com.ibm.ws.runtime.component.ContainerImpl.startCo mponents(ContainerImpl.java:821)
            at com.ibm.ws.runtime.component.ContainerImpl.start(C ontainerImpl.java:649)
            at com.ibm.ws.runtime.component.ServerImpl.start(Serv erImpl.java:356)
            at com.ibm.ws.runtime.WsServerImpl.bootServerContaine r(WsServerImpl.java:173)
            at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl .java:120)
            at com.ibm.ws.runtime.WsServerImpl.main(WsServerImpl. java:378)
            at com.ibm.ws.runtime.WsServer.main(WsServer.java:50)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:85)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:58)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:60)
            at java.lang.reflect.Method.invoke(Method.java:391)
            at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.ja va:190)
            Caused by: javax.naming.NameNotFoundException: Name "comp/websphere/UOWManager" not found in context "java:".

            Code:
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
            
            <beans>
                <bean id="jmsFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
            		<property name="jndiName" value="jms/BCSSConFactory" />
            	</bean>
            
            	<bean id="MQPoolQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
            		<property name="jndiName" value="jms/MQPoolQueue" />
            	</bean>
            
            	<bean id="NcdJtaDS" class="org.springframework.jndi.JndiObjectFactoryBean">
            		<property name="jndiName">
            	      <value>java:comp/websphere/UOWManager</value>
            	    </property>
            	</bean>
            
                <bean id="messageListener" class="tw.com.tdcc.listener.MQPoolQueueMessageListener">
                	<property name="dataSource">
            			<ref bean="NcdJtaDS"/>
            		</property>
            		<property name="transactionManager">
                        <ref bean="transactionManager"/>
                    </property>
            	</bean>
            
            	<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
            	    <property name="connectionFactory" ref="jmsFactory"/>
            	    <property name="destination" ref="MQPoolQueue"/>
            	    <property name="messageListener" ref="messageListener"/>
            	    <property name="transactionManager" ref="transactionManager"/>
            	    <property name="taskExecutor" ref="myTaskExecutor" />
            	</bean>
            
            	<bean id="myTaskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
                  <property name="workManagerName" value="wm/default" />
                </bean>
            
                <bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
            </beans>
            Code:
            public class MQPoolQueueMessageListener implements MessageListener {
            
            	private static final Logger logger = LoggerFactory
            			.getLogger(MQPoolQueueMessageListener.class);
            
            	private WebSphereUowTransactionManager transactionManager;
            
            	private DataSource dataSource;
            
            	/**
            	 * @return Returns the transactionManager.
            	 */
            	public WebSphereUowTransactionManager getTransactionManager() {
            		return transactionManager;
            	}
            	/**
            	 * @param transactionManager The transactionManager to set.
            	 */
            	public void setTransactionManager(WebSphereUowTransactionManager transactionManager) {
            		this.transactionManager = transactionManager;
            	}
            	/**
            	 * @return Returns the dataSource.
            	 */
            	public DataSource getDataSource() {
            		return dataSource;
            	}
            
            	/**
            	 * @param dataSource
            	 *            The dataSource to set.
            	 */
            	public void setDataSource(DataSource dataSource) {
            		this.dataSource = dataSource;
            	}
            
            	/*
            	 * (non-Javadoc)
            	 * 
            	 * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
            	 */
            	public void onMessage(Message message) {
            		if (message instanceof TextMessage) {
            			TextMessage tm = (TextMessage) message;
            			try {
            				logger.info("MQPoolQueue receive message:" + tm.getText());
            				logger.info("ncdJtaTransactionManager:"
            						+ transactionManager);
            				logger.info("dataSource:" + dataSource);
            				TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
            				transactionTemplate
            						.execute(new TransactionCallbackWithoutResult() {
            							public void doInTransactionWithoutResult(
            									TransactionStatus status) {
            								JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
            								StringBuffer sb = new StringBuffer();
            								sb.append("INSERT INTO IBMSF.BCSSUSER(CREATR_ID,CREATR_PRTY_ID,USER_NM,PASSWORD,LOGGED_ON,PW_EXPIRATION_DT,");
            								sb.append("MGR_ID,USER_ID,PRTY_ID,UPDR_ID,UPDR_PRTY_ID,ST) ");
            								sb.append("VALUES('SYSOP', 'FISC', 'System Operator', 'xxx', '0', '2009-12-22', 'FISC', 'xxx', 'FISC', 'xxx', 'FISC', 1)");
            								jdbcTemplate.update(sb.toString());
            								sb.delete(0, sb.length());
            								sb.append("delete from ibmsf.BCSS_PARAM where PARAM_NAME='XXX' and PARAM_TYPE='S'");
            								jdbcTemplate.update(sb.toString());								
            							}
            				});		
            				if (true) {
            					try {
            						throw new RuntimeException("");
            					} catch (Exception e) {
            						// TODO Auto-generated catch block
            						e.printStackTrace();
            					}
            				}
            			} catch (JMSException e) {
            				logger.error("JMSException:", e);
            			} catch (RuntimeException re) {
            				logger.error("RuntimeException:", re);
            			}
            		}
            	}
            
            }
            Last edited by jamiechen98; Dec 23rd, 2009, 03:03 AM.

            Comment

            Working...
            X