我在JBOSS MQ中使用了Spring JmsTemplate。我需要在jmsTemplate配置文件中使用"sessionTransacted“属性吗?如果我不专门配置它,它的默认值是多少?
发布于 2015-07-26 10:58:18
您可以使用如下配置:
<!-- 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>你的javax.jms.MessageListener实现应该结构化,以便重新抛出异常,以便通知失败:
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");
}https://stackoverflow.com/questions/31632954
复制相似问题