简体   繁体   English

在收听jms主题时删除消息

[英]Dropping messages when listening to a jms topic

I am using spring jms listener as defined below. 我正在使用如下定义的spring jms监听器。 and it generally works fine however i see a it constantly disconnecting and reconnecting based on the recieveTimeout setting. 它通常工作正常但我看到它根据recieveTimeout设置不断断开连接并重新连接。

<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <!-- mrgm connection to the jca adapter -->
    <property name="connectionFactory" ref="mrgmConnectionFactory" />
    <!-- name of the topic -->
    <property name="destinationName" value="test.destinationname" />
    <!-- class which will listen for messages (must implement javax.jms.MessageListener -->
    <property name="messageListener" ref="TestListener" />
    <property name="sessionTransacted" value="true" />
    <property name="receiveTimeout" value="1000" />
            <!--turning this on drops all messages -->
            <!--        <property name="pubSubDomain" value="true" /> -->

</bean>

I have done some test and when there are alot of messages being posted to the topic it will drop some because if the message comes during the small period between the disconnect and reconnect it will obviously be missed by the listener. 我已经做了一些测试,当有很多消息被发布到主题时,它会丢弃一些,因为如果消息在断开连接和重新连接之间的小时间段内出现,那么听众显然会错过它。

if i set the recieveTimeout to 0 this problem goes away. 如果我将recieveTimeout设置为0,这个问题就会消失。 should i always set the recieveTimeout to 0 when listenting on a topic? 我是否总是在持续主题时将recieveTimeout设置为0? or am I going about this whole process the wrong way. 或者我是以错误的方式进行整个过程。

When disconnecting and reconnecting, if your subscriber is not durable, you might loose messages. 断开连接并重新连接时,如果您的用户不耐用,您可能会丢失消息。 However the spring DMLC should not reconnect. 但弹簧DMLC不应重新连接。 Can you troubleshoot that a bit more? 你可以解决这个问题吗? It should essentially subscribe to a topic session.createConsumer(..) then loop consumer.receive() or consumer.receive(timeout) . 它本质上应该订阅一个主题session.createConsumer(..)然后循环consumer.receive()consumer.receive(timeout) Not sure why your DMLC reconnects when setting the timeout higher. 将超时设置更高时,不确定为什么DMLC会重新连接。

You should be fine with no timeout, though, but you might want to track the cause to the reconnect with debug logging etc. 不过没有超时,你应该没问题,但是你可能想跟踪调试日志记录等重新连接的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM