activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Netlancer (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AMQ-5410) Out of order messages received in MQTT network of brokers
Date Fri, 31 Oct 2014 14:52:34 GMT

     [ https://issues.apache.org/jira/browse/AMQ-5410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Netlancer updated AMQ-5410:
---------------------------
    Description: 
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

  was:
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.


> 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)

Mime
View raw message