Here are the examples of the java api class org.apache.activemq.artemis.tests.integration.mqtt.imported.MQTTClientProvider taken from open source projects.
1. StompTest#sendSTOMPReceiveMQTT()
Project: activemq-artemis
File: StompTest.java
File: StompTest.java
@Test public void sendSTOMPReceiveMQTT() throws Exception { String address = "myTestAddress"; // Set up MQTT Subscription MQTTClientProvider clientProvider = new FuseMQTTClientProvider(); clientProvider.connect("tcp://localhost:61616"); clientProvider.subscribe(address, 0); String stompPayload = "This is a test message"; // Set up STOMP connection and send STOMP Message String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL; sendFrame(frame); frame = "SEND\n" + "destination:" + address + "\n\n" + stompPayload + Stomp.NULL; sendFrame(frame); // Recieve MQTT Message byte[] mqttPayload = clientProvider.receive(10000); clientProvider.disconnect(); assertEquals(stompPayload, new String(mqttPayload, "UTF-8")); clientProvider.disconnect(); }
2. StompTest#sendMQTTReceiveSTOMP()
Project: activemq-artemis
File: StompTest.java
File: StompTest.java
@Test public void sendMQTTReceiveSTOMP() throws Exception { String address = "myTestAddress"; String payload = "This is a test message"; server.getActiveMQServer().createQueue(new SimpleString(address), new SimpleString(address), null, false, false); // Set up STOMP subscription String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL; sendFrame(frame); frame = "SUBSCRIBE\n" + "destination:" + address + "\n" + "ack:auto\n\n" + Stomp.NULL; sendFrame(frame); receiveFrame(1000); // Send MQTT Message MQTTClientProvider clientProvider = new FuseMQTTClientProvider(); clientProvider.connect("tcp://localhost:61616"); clientProvider.publish(address, payload.getBytes(), 0); clientProvider.disconnect(); // Receive STOMP Message frame = receiveFrame(1000); assertTrue(frame.contains(payload)); }