【问题标题】:When activemq networkconnector was setting, topic message expired设置 activemq 网络连接器时,主题消息已过期
【发布时间】:2015-03-22 06:30:14
【问题描述】:

经纪人 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。 我向 Broker 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();

但是,一旦向 Broker 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,目的地= 主题://a.b.c.e,transactionId = null,过期 = 1421999420843, 时间戳 = 1421999415843,到达 = 0,brokerInTime = 1421999501929, brokerOutTime = 0,correlationId = null,replyTo = null,persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,compressed = false,userID = null,content = org.apache.activemq.util.ByteSequence@457096, marshalledProperties = 空,dataStructure = null,redeliveryCounter = 0,大小 = 0, 属性 = null,readOnlyProperties = false,readOnlyBody = false, droppable = 假,jmsXGroupFirstForConsumer = 假} ActiveMQMapMessage{ theTable = {} } | org.apache.activemq.broker.region.RegionBroker | ActiveMQ 传输: tcp:///xxx.xxx.xxx.xxx:50763@61616

删除此代码('topicPublisher.setTimeToLive(5000);') 后,成功。 为什么这段代码有问题?

【问题讨论】:

    标签: java activemq ttl


    【解决方案1】:

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

    【讨论】:

    • 一旦向Broker B发布消息,消息就过期了。
    【解决方案2】:

    它解决了问题。

    activemq.xml

    <plugins>
        <timeStampingBrokerPlugin/>
    </plugins>
    

    【讨论】:

      猜你喜欢
      • 2017-10-18
      • 2021-11-14
      • 1970-01-01
      • 1970-01-01
      • 2019-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      相关资源
      最近更新 更多