Announcement Announcement Module
Collapse
No announcement yet.
JmsTemplate not getting UowTransaction manager from Websphere 7 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JmsTemplate not getting UowTransaction manager from Websphere 7

    Hi,

    I am using JMSTemplate to send Object message in the websphere Queue. My code is just running fine and currently not giving any problem except that i have configured WebSphereUowTransactionManager with spring annotation driven transaction management support. I wrote a test code to send same message in two of the WAS 7 Queues. after sending one message i explicitly throw and exception to chk whether its rolling back or not. But the transaction is not rolled back.

    Following are my JMS application context file settings:

    Code:
    <jee:jndi-lookup id="connectionFactory" jndi-name="jms/msgConnectionFactory"/>
    	
    <jee:jndi-lookup id="destination2" jndi-name="jms/msgQueue2"/>
    <jee:jndi-lookup id="destination3" jndi-name="jms/msgQueue3"/>
    
    <beans:bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager">
    </beans:bean>
    	
    <tx:annotation-driven transaction-manager="transactionManager"/> 
    
    <!-- MessageSender Bean config -->
    <beans:bean id="messageSender" class="com.emaratech.integration.service.MessageSender">
    	<beans:property name="jmsTemplate" ref="jmsTemplate"></beans:property>
    <beans:property name="jmsTemplate2" ref="jmsTemplate2"></beans:property>
    </beans:bean>
    
    <!-- JMS template settings -->
    <beans:bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate" >
    	<beans:property name="connectionFactory" ref="connectionFactory" />
    	<beans:property name="defaultDestination" ref="destination3" />
    	<beans:property name="sessionTransacted" value="true" />
    	<beans:property name="sessionAcknowledgeMode">
      		<util:constant static-field="javax.jms.Session.SESSION_TRANSACTED "/>
    	</beans:property> 
    </beans:bean>
    	
    <beans:bean id="jmsTemplate2" class="org.springframework.jms.core.JmsTemplate" >
    	<beans:property name="connectionFactory" ref="connectionFactory" />
    	<beans:property name="defaultDestination" ref="destination2" />
    	<beans:property name="sessionTransacted" value="true" />
    	<beans:property name="sessionAcknowledgeMode">
     		<util:constant static-field="javax.jms.Session.SESSION_TRANSACTED "/>
    	</beans:property> 
    </beans:bean>
    And Following is my message sending method code:
    Code:
    @Transactional(readOnly=false, propagation = Propagation.REQUIRES_NEW)
    public void sendStringMessage(final String strMsg){
    	log.info("strMsg: " + strMsg);
    	try{
    		jmsTemplate.send(new MessageCreator(){
    			
    			public Message createMessage(Session session) throws JMSException {
    				TextMessage objMsg = session.createTextMessage();
    				objMsg.setText(strMsg);
    				return objMsg;
    			}
    				
    		});
    		log.info("msg from jms template 1 sent");
    			
    		if("001".equals(strMsg)){
    			log.info("exception throwing after template 1");
    			throw new RuntimeException("Self thrown Exception");
    		}
    			
    			
    		jmsTemplate2.send(new MessageCreator(){
    				
    			public Message createMessage(Session session) throws JMSException {
    				TextMessage objMsg = session.createTextMessage();
    				objMsg.setText(strMsg);
    				return objMsg;
    			}
    				
    		});
    		log.info("msg from jms template 2 sent");
    		
    		if("002".equals(strMsg)){
    			log.info("exception throwing after template 2");
    			throw new RuntimeException("Self thrown Exception");
    		}
    	}catch (Exception e) {
    		e.printStackTrace();
    	}
    		
    		
    		
    	if("003".equals(strMsg)){
    		log.info("exception throwing after everything");
    		throw new RuntimeException("Self thrown Exception");
    	}
    	
    }

    Your help in this matter will be highly appreciated.

    Regards,
    Saif Khan
Working...
X