繁体   English   中英

设置activemq networkconnector时,主题消息已过期

[英]When activemq networkconnector was setting, topic message expired

经纪人A.

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="mqtt_1" dataDirectory="${activemq.data}" persistent="true" schedulePeriodForDestinationPurge="13000" offlineDurableSubscriberTimeout="90000" offlineDurableSubscriberTaskSchedule="20000" useJmx="true">
</broker>

经纪人B.

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="mqtt_2" dataDirectory="${activemq.data}" persistent="true" schedulePeriodForDestinationPurge="13000" offlineDurableSubscriberTimeout="90000" offlineDurableSubscriberTaskSchedule="20000" useJmx="true">
    <networkConnectors>
        <networkConnector
            name="mqtt_2"
            uri="static:(tcp://BrokerA IP:61616)"
            conduitSubscriptions="false"
            dynamicOnly="true"
            prefetchSize="1"
            networkTTL="1"
            messageTTL="1"
            consumerTTL="1"
            />
        </networkConnectors> </broker>

订阅者已连接到代理A。我向代理B发布了一条消息。

String url = "tcp://Broker B IP:61616";
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
TopicConnection tpConnection = connectionFactory.createTopicConnection();
tpConnection.start();
TopicSession tpSession = tpConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = tpSession.createTopic("a/b/c/e");
TopicPublisher topicPublisher = tpSession.createPublisher(topic);
topicPublisher.setTimeToLive(5000);

MapMessage map = tpSession.createMapMessage();
map.setString("test", "value");
topicPublisher.publish(map);

tpConnection.stop();
topicPublisher.close();
tpSession.close();
tpConnection.close();

但是,一旦向代理B发布消息,该消息就过期了

2015-01-23 16:51:41,930 | 调试| 邮件已过期ActiveMQMapMessage {commandId = 6,responseRequired = true,messageId = ID:test.local-50762-1421999415422-1:1:1:1:1,originalDestination = null,originalTransactionId = null,producerId = ID:test.local- 50762-1421999415422-1:1:1:1,目标= topic:// abce,transactionId =空,到期时间= 1421999420843,时间戳= 1421999415843,到达= 0,brokerInTime = 1421999501929,brokerOutTime = 0,相关ID =空,replyTo = null,持久性= true,类型= null,优先级= 4,groupID = null,groupSequence = 0,targetConsumerId = null,压缩= false,userID = null,content = org.apache.activemq.util.ByteSequence @ 457096,marshalledProperties = null,dataStructure = null,redeliveryCounter = 0,大小= 0,属性= null,readOnlyProperties = false,readOnlyBody = false,droppable = false,jmsXGroupFirstForConsumer = false} ActiveMQMapMessage {theTable = {}} | org.apache.activemq.broker.region.RegionBroker | ActiveMQ传输:tcp:///xxx.xxx.xxx.xxx:50763 @ 61616

删除此代码( “ topicPublisher.setTimeToLive(5000);” )后,成功。 为什么这段代码是问题所在?

topicPublisher.setTimeToLive(5000)使消息在5秒后过期。

它解决了问题。

activemq.xml

<plugins>
    <timeStampingBrokerPlugin/>
</plugins>

暂无
暂无

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

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