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?
Asked
Active
Viewed 1,108 times
1 Answers
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
-
Why do I need "sessionTransacted" ? What is the significance of this? – Avijit Samal Jul 26 '15 at 03:25
-
This should help :https://docs.oracle.com/javaee/7/api/index.html?javax/jms/Connection.html read on createSession related methods. – jithin iyyani Jul 26 '15 at 03:44