首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring jmstemplate属性配置

Spring jmstemplate属性配置
EN

Stack Overflow用户
提问于 2015-07-26 10:05:53
回答 1查看 981关注 0票数 0

我在JBOSS MQ中使用了Spring JmsTemplate。我需要在jmsTemplate配置文件中使用"sessionTransacted“属性吗?如果我不专门配置它,它的默认值是多少?

EN

回答 1

Stack Overflow用户

发布于 2015-07-26 10:58:18

您可以使用如下配置:

代码语言:javascript
复制
   <!-- 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实现应该结构化,以便重新抛出异常,以便通知失败:

代码语言:javascript
复制
  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");

    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31632954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档