Spring jmstemplate конфигурация свойств
Я использую Spring JmsTemplate с JBOSS MQ. Нужно ли использовать свойство "sessionTransacted" в моем файле конфигурации jmsTemplate? Каково значение по умолчанию для этого, если я не настраиваю это исключительно?
1 ответ
Вы можете иметь свой конфиг что-то вроде этого:
<!-- 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");
}