[
https://issues.apache.org/jira/browse/AMQ-5410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14193333#comment-14193333
]
Netlancer commented on AMQ-5410:
--------------------------------
Thanks for your input. Setting the prefetch limit to 1 and only doing a proper
disconnect results in message order.
Regarding disconnects:
considering an mobile usecase, Proper disconnects may not come. Is there a way
to prevent this ? Also, setting a low keepalive timeout will not be feasible
always.
> Out of order messages received in MQTT network of brokers
> ---------------------------------------------------------
>
> Key: AMQ-5410
> URL: https://issues.apache.org/jira/browse/AMQ-5410
> Project: ActiveMQ
> Issue Type: Bug
> Components: MQTT
> Affects Versions: 5.11.0
> Reporter: Netlancer
>
> broker network setup with mqtt enabled.
> scenario:
> Client (C1) connects to MQ1
> C1 publishes message M1 to topic T1
> C1 receives the message M1 by doing receive using mqtt client.
> C1 publishes message M2,M3 to topic T1 and disconnects.
> C1 connects back to MQ2
> C1 does a receive. Now M3 is received first instead of M2.
> The following testcase shows the issues. The testcase is part of
> activemq-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.java
>
> {code:title=MQTTNetworkOfBrokersFailoverTest.java|borderStyle=solid}
> @Test
> public void testOutOfOrderMessageScenario() throws Exception{
> // A Consumer subscribing to an topic and Publishing to the same
> topic receives the messages out of order
> // and some messages lost
> // after failing over and connecting to other broker
> CountDownLatch consumerNetworked = listenForConsumersOn(broker);
> MQTT localMqtt = createMQTTTcpConnection("foo", false,
> localBrokerMQTTPort);
> BlockingConnection localConn = localMqtt.blockingConnection();
> localConn.connect();
> localConn.subscribe(new Topic[]{new Topic("foo/bar",
> QoS.EXACTLY_ONCE)});
> String msg = "Hello, World!";
> localConn.publish("foo/bar", msg.getBytes(), QoS.EXACTLY_ONCE, false);
> localConn.publish("foo/bar", "2".getBytes(), QoS.EXACTLY_ONCE, false);
> localConn.publish("foo/bar", "3".getBytes(), QoS.EXACTLY_ONCE, false);
> localConn.publish("foo/bar", "4".getBytes(), QoS.EXACTLY_ONCE, false);
> localConn.publish("foo/bar", "5".getBytes(), QoS.EXACTLY_ONCE, false);
> org.fusesource.mqtt.client.Message receiveMsg =
> localConn.receive(100, TimeUnit.SECONDS);
> assertNotNull(receiveMsg);
> receiveMsg.ack();
> String response = new String(receiveMsg.getPayload());
> assertEquals(msg, response);
> MQTT remoteMqtt = createMQTTTcpConnection("foo", false,
> remoteBrokerMQTTPort);
> BlockingConnection remoteConn = remoteMqtt.blockingConnection();
> remoteConn.connect();
> receiveMsg = remoteConn.receive(100, TimeUnit.SECONDS);
> assertNotNull(receiveMsg);
> receiveMsg.ack();
> response = new String(receiveMsg.getPayload());
> assertEquals("2", response);
> }
> {code}
> results in
> junit.framework.ComparisonFailure:
> Expected :2
> Actual :3
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)