Package org.eclipse.paho.client.mqttv3.persist

Examples of org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence


        Assert.assertEquals(1, receivedMessages.size());
        client.disconnect();
    }

    private void publish(MqttClient client, String topicName, int qos, byte[] payload) throws MqttException {
      MqttTopic topic = client.getTopic(topicName);
       MqttMessage message = new MqttMessage(payload);
      message.setQos(qos);
      MqttDeliveryToken token = topic.publish(message);
      token.waitForCompletion();
    }
View Full Code Here


        MqttMessage message = new MqttMessage(payload);
        message.setQos(qos);
        message.setRetained(retain);

        // publish message asynchronously
        MqttTopic mqttTopic = client.getTopic(topic);
        MqttDeliveryToken deliveryToken = mqttTopic.publish(message);

        logger.debug("Publishing message {} to topic '{}'",
            deliveryToken.getMessageId(), topic);
        if (!async) {
          // wait for publish confirmation
View Full Code Here

        conOpts.setCleanSession(true);
        conOpts.setKeepAliveInterval(60);
    }

    public void testConnectFirst() throws MqttException, IOException, InterruptedException {
        NetworkModule networkModule = new TCPNetworkModule(SocketFactory.getDefault(), host, port, "");
        networkModule.start();
        MqttInputStream  mqttIn  = new MqttInputStream (networkModule.getInputStream());
        MqttOutputStream mqttOut = new MqttOutputStream(networkModule.getOutputStream());
        try {
            mqttOut.write(new MqttPingReq());
            mqttOut.flush();
            mqttIn.readMqttWireMessage();
            fail("Error expected if CONNECT is not first packet");
View Full Code Here

        conOpts.setCleanSession(true);
        conOpts.setKeepAliveInterval(60);
    }

    public void testConnectFirst() throws MqttException, IOException, InterruptedException {
        NetworkModule networkModule = new TCPNetworkModule(SocketFactory.getDefault(), host, port, "");
        networkModule.start();
        MqttInputStream  mqttIn  = new MqttInputStream (networkModule.getInputStream());
        MqttOutputStream mqttOut = new MqttOutputStream(networkModule.getOutputStream());
        try {
            mqttOut.write(new MqttPingReq());
            mqttOut.flush();
            mqttIn.readMqttWireMessage();
            fail("Error expected if CONNECT is not first packet");
View Full Code Here

    }

    public void testConnectFirst() throws MqttException, IOException, InterruptedException {
        NetworkModule networkModule = new TCPNetworkModule(SocketFactory.getDefault(), host, port, "");
        networkModule.start();
        MqttInputStream  mqttIn  = new MqttInputStream (networkModule.getInputStream());
        MqttOutputStream mqttOut = new MqttOutputStream(networkModule.getOutputStream());
        try {
            mqttOut.write(new MqttPingReq());
            mqttOut.flush();
            mqttIn.readMqttWireMessage();
            fail("Error expected if CONNECT is not first packet");
        } catch (IOException _) {}
    }
View Full Code Here

    public void testConnectFirst() throws MqttException, IOException, InterruptedException {
        NetworkModule networkModule = new TCPNetworkModule(SocketFactory.getDefault(), host, port, "");
        networkModule.start();
        MqttInputStream  mqttIn  = new MqttInputStream (networkModule.getInputStream());
        MqttOutputStream mqttOut = new MqttOutputStream(networkModule.getOutputStream());
        try {
            mqttOut.write(new MqttPingReq());
            mqttOut.flush();
            mqttIn.readMqttWireMessage();
            fail("Error expected if CONNECT is not first packet");
        } catch (IOException _) {}
    }
View Full Code Here

        NetworkModule networkModule = new TCPNetworkModule(SocketFactory.getDefault(), host, port, "");
        networkModule.start();
        MqttInputStream  mqttIn  = new MqttInputStream (networkModule.getInputStream());
        MqttOutputStream mqttOut = new MqttOutputStream(networkModule.getOutputStream());
        try {
            mqttOut.write(new MqttPingReq());
            mqttOut.flush();
            mqttIn.readMqttWireMessage();
            fail("Error expected if CONNECT is not first packet");
        } catch (IOException _) {}
    }
View Full Code Here

      sslProperties.put("com.ibm.ssl.trustStore", trustStore);
    }
    mqttConnectOptions.setSSLProperties(sslProperties);

    try {
      mqttClient = new MqttClient(serverURI, clientId, new MemoryPersistence());
      mqttClient.connect(mqttConnectOptions);
      logger.info("MQTT client connected");
    } catch (MqttException e) {
      logger.warn("Failed to initialize MQTT event client", e); //$NON-NLS-1$
    }
View Full Code Here

        ActiveMQConnection activeMQConnection = (ActiveMQConnection) new ActiveMQConnectionFactory(openwireTransport.getConnectUri()).createConnection();
        activeMQConnection.start();
        Session s = activeMQConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer = s.createConsumer(s.createTopic("test"));

        MqttClient client = new MqttClient("tcp://localhost:" + mqttConnector.getConnectUri().getPort(), "clientid", new MemoryPersistence());
        client.connect();
        client.publish("test", "hello".getBytes(), 1, false);

        Message msg = consumer.receive(100 * 5);
        assertNotNull(msg);
View Full Code Here

            Thread.sleep(10);
            new Thread(null, null, "client:"+i) {
                @Override
                public void run() {
                    try {
                        MqttClient client = new MqttClient("tcp://localhost:" + mqttConnector.getConnectUri().getPort(), Thread.currentThread().getName(), new MemoryPersistence());
                        client.connect();
                        connectedDoneLatch.countDown();
                        sendBarrier.await();
                        for( int i=0; i < 10; i++) {
                           Thread.sleep(1000);
View Full Code Here

TOP

Related Classes of org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence

Copyright © 2018 www.massapicom. 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.