ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ backout and spring

Post new topic  Reply to topic
 MQ backout and spring « View previous topic :: View next topic » 
Author Message
matpil
PostPosted: Mon Feb 04, 2008 5:40 am    Post subject: MQ backout and spring Reply with quote

Newbie

Joined: 04 Feb 2008
Posts: 2



Hi all!
I need an helping hand to implement the backout function using spring.

by th way, I can implement the backout with a simple java class:

Code:

public void sendMessage() throws Exception
 {

          private MQQueueManager m_mqQueueManager = ....;
         
            m_mqMessageO=new MQMessage();

        try
        {
                m_mqMessageO.format=MQC.MQFMT_STRING;
                m_mqMessageO.writeString(record_read);
                m_mqMessageO.messageId=m_mqMessage.messageId;
                m_mqMessageO.correlationId=m_mqMessage.correlationId;
                for (int i = 0; i < GetFromCacheMQ.coda_tx.length; i++) {
                m_mqQueueO[i].put(m_mqMessageO);
               
        }     

    m_mqQueueManager.commit();
                                   
        }
        catch (Exception mqExp)
        {
                m_mqQueueManager.backout();   
                mqExp.printStackTrace();
        }

 }


Now, I convert all my framework using spring and I can't find a method to implement this function. How I can create by spring a "MQQueueManager" object to call that function?

My xml spring file:
Code:

   <bean id="propertyConfigurer"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="location">
         <value>myProp.properties</value>
      </property>
   </bean>

   <!-- JNDI Environment Template -->
   <bean id="jndiTemplate"
      class="org.springframework.jndi.JndiTemplate">
      <property name="environment">
         <props>
            <prop key="java.naming.factory.initial">
               com.ibm.mq.jms.context.WMQInitialContextFactory
            </prop>
            <prop key="java.naming.provider.url">
               ${CACHE.MQ.HOST}:${CACHE.MQ.PORT}
            </prop>
         </props>
      </property>
   </bean>

   <bean id="jmsQueueConnectionFactory"
      class="com.ibm.mq.jms.MQQueueConnectionFactory">
      <property name="queueManager">
         <value>${CACHE.MQ.QUEUEMANAGER}</value>
      </property>
      <property name="hostName">
         <value>${CACHE.MQ.HOST}</value>
      </property>
      <property name="port">
         <value>${CACHE.MQ.PORT}</value>
      </property>
      <property name="channel">
         <value>${CACHE.MQ.CHANNEL}</value>
      </property>
      <property name="transportType">
         <value>1</value>
      </property>
   </bean>

   <bean id="jmsDestinationResolver" class="com.ibm.mq.jms.MQQueue">
      <constructor-arg value="CACHE" />
   </bean>

   <!-- JMS Queue Template -->
   <bean id="jmsTemplate"
      class="org.springframework.jms.core.JmsTemplate102">
      <property name="connectionFactory">
         <ref bean="jmsQueueConnectionFactory" />
      </property>
      <property name="defaultDestination">
         <ref bean="jmsDestinationResolver" />
      </property>
      <property name="pubSubDomain">
         <value>false</value>
      </property>
      <!--
         <property name="receiveTimeout">
         <value>20000</value>
         </property>
      -->
   </bean>

   <bean id="jmsQueueReceiver"
      class="it.pitagora.sqtp.cache.receiver.JmsReceiver">
      <property name="jmsTemplate">
         <ref bean="jmsTemplate" />
      </property>
   </bean>



Thanks in advance!

Regard,
matpil
Back to top
View user's profile Send private message
JLRowe
PostPosted: Tue Feb 05, 2008 6:15 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

Rollback is done via javax.jms.Session, the jmstemplate does not expose the session directly.

Instead, you need to implement a SessionCallback and run it via the execute() method of the JMSTemplate. Check the javadoc.

Alternatively, you can use the spring transaction support, this way your code need not be aware of the underlying resource managers. Check out JmsTransactionManager in the javadoc.

Persevere with the spring documentation, it's well worth the effort.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ backout and spring
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.