簡體   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