0

I am using the Spring JmsTemplate with JBOSS MQ. Do I need to use the "sessionTransacted" property in my jmsTemplate configuration file? What is the default value for this, if I do not configure it exclusively?

1 Answers1

0

You can have your config something like this:

   <!-- this is the Message Driven POJO (MDP) -->
<bean id="messageListener" class="jmsexample.ExampleListener" />

<!-- and this is the message listener container -->
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="destination" ref="destination"/>
    <property name="messageListener" ref="messageListener" />
    <property name="sessionTransacted" value="true" />
   <property name="concurrentConsumers" value="5" />
</bean>

Your implementation of javax.jms.MessageListener should be structured so as to rethrow exception so as to notifiy failure:

  public void onMessage(final Message message) {

        LOGGER.debug("MessageReceiver::onMessage started");
        try {
          //do you service related operations here 
        } catch (Exception ex) {
            LOGGER.error("Error while performing popration", ex);

            throw new RuntimeException("Exception in procesing message");
        }
        LOGGER.debug("MessageReceiver::onMessage completed");

    }
jithin iyyani
  • 751
  • 1
  • 7
  • 19