Package org.fusesource.mqtt.client

Examples of org.fusesource.mqtt.client.BlockingConnection.publish()


        final String RETAINED = "RETAINED";
        connection.publish("one", RETAINED.getBytes(), QoS.AT_LEAST_ONCE, true);
        connection.publish("two", RETAINED.getBytes(), QoS.AT_LEAST_ONCE, true);

        final String NONRETAINED = "NONRETAINED";
        connection.publish("one", NONRETAINED.getBytes(), QoS.AT_LEAST_ONCE, false);
        connection.publish("two", NONRETAINED.getBytes(), QoS.AT_LEAST_ONCE, false);

        connection.subscribe(new Topic[]{new Topic("#", QoS.AT_LEAST_ONCE)});
        for (int i = 0; i < 4; i++) {
            final Message message = connection.receive(30, TimeUnit.SECONDS);
View Full Code Here


        connection.publish("one", RETAINED.getBytes(), QoS.AT_LEAST_ONCE, true);
        connection.publish("two", RETAINED.getBytes(), QoS.AT_LEAST_ONCE, true);

        final String NONRETAINED = "NONRETAINED";
        connection.publish("one", NONRETAINED.getBytes(), QoS.AT_LEAST_ONCE, false);
        connection.publish("two", NONRETAINED.getBytes(), QoS.AT_LEAST_ONCE, false);

        connection.subscribe(new Topic[]{new Topic("#", QoS.AT_LEAST_ONCE)});
        for (int i = 0; i < 4; i++) {
            final Message message = connection.receive(30, TimeUnit.SECONDS);
            assertNotNull("Should receive 4 messages", message);
View Full Code Here

        notClean.connect();
        Message msg = notClean.receive(10000, TimeUnit.MILLISECONDS);
        assertNotNull(msg);
        assertEquals(TOPIC, new String(msg.getPayload()));
        msg.ack();
        notClean.publish(TOPIC, TOPIC.getBytes(), QoS.EXACTLY_ONCE, false);
        notClean.disconnect();

        // MUST NOT receive message from previous not clean session
        final MQTT mqttClean = createMQTTConnection(CLIENTID, true);
        final BlockingConnection clean = mqttClean.blockingConnection();
View Full Code Here

        final BlockingConnection clean = mqttClean.blockingConnection();
        clean.connect();
        msg = clean.receive(10000, TimeUnit.MILLISECONDS);
        assertNull(msg);
        clean.subscribe(new Topic[] { new Topic(TOPIC, QoS.EXACTLY_ONCE) });
        clean.publish(TOPIC, TOPIC.getBytes(), QoS.EXACTLY_ONCE, false);
        clean.disconnect();

        // MUST NOT receive message from previous clean session
        notClean = mqttNotClean.blockingConnection();
        notClean.connect();
View Full Code Here

        BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();

        final String DOLLAR_TOPIC = "$TopicA";
        connection.subscribe(new Topic[] { new Topic(DOLLAR_TOPIC, QoS.EXACTLY_ONCE)});
        connection.publish(DOLLAR_TOPIC, DOLLAR_TOPIC.getBytes(), QoS.EXACTLY_ONCE, true);

        Message message = connection.receive(10, TimeUnit.SECONDS);
        assertNull("Publish enabled for $ Topics by default", message);
        connection.disconnect();
View Full Code Here

        mqtt.setKeepAlive((short) 2);
        connection = mqtt.blockingConnection();
        connection.connect();

        connection.subscribe(new Topic[] { new Topic(DOLLAR_TOPIC, QoS.EXACTLY_ONCE)});
        connection.publish(DOLLAR_TOPIC, DOLLAR_TOPIC.getBytes(), QoS.EXACTLY_ONCE, true);

        message = connection.receive(10, TimeUnit.SECONDS);
        assertNotNull(message);
        message.ack();
        assertEquals("Message body", DOLLAR_TOPIC, new String(message.getPayload()));
View Full Code Here

        MQTT mqtt = createMQTTConnection(clientId, false);
        mqtt.setKeepAlive((short) 2);
        final BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();
        final String TOPICA = "TopicA";
        connection.publish(TOPICA, TOPICA.getBytes(), QoS.EXACTLY_ONCE, true);

        MQTT mqtt1 = createMQTTConnection(clientId, false);
        mqtt1.setKeepAlive((short) 2);
        final BlockingConnection connection1 = mqtt1.blockingConnection();
        connection1.connect();
View Full Code Here

            public boolean isSatisified() throws Exception {
                return !connection.isConnected();
            }
        }));

        connection1.publish(TOPICA, TOPICA.getBytes(), QoS.EXACTLY_ONCE, true);
        connection1.disconnect();

        // disable link stealing
        stopBroker();
        protocolConfig = "allowLinkStealing=false";
View Full Code Here

        mqtt = createMQTTConnection(clientId, false);
        mqtt.setKeepAlive((short) 2);
        final BlockingConnection connection2 = mqtt.blockingConnection();
        connection2.connect();
        connection2.publish(TOPICA, TOPICA.getBytes(), QoS.EXACTLY_ONCE, true);

        mqtt1 = createMQTTConnection(clientId, false);
        mqtt1.setKeepAlive((short) 2);
        final BlockingConnection connection3 = mqtt1.blockingConnection();
        try {
View Full Code Here

            MQTT mqtt = createMQTTConnection(clientId, false);
            mqtt.setKeepAlive((short) 2);
            final BlockingConnection connection = mqtt.blockingConnection();
            connection.connect();
            connection.publish(TOPICA, TOPICA.getBytes(), QoS.EXACTLY_ONCE, true);

            assertTrue("Client connect failed for attempt: " + i, Wait.waitFor(new Wait.Condition() {
                @Override
                public boolean isSatisified() throws Exception {
                    return connection.isConnected();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.