org.eclipse.paho.client.mqttv3.IMqttClient Java Examples
The following examples show how to use
org.eclipse.paho.client.mqttv3.IMqttClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MqttUtils.java From enmasse with Apache License 2.0 | 5 votes |
public static List<CompletableFuture<MqttMessage>> subscribeAndReceiveMessages(IMqttClient client, String address, int size, int qos) throws MqttException { List<CompletableFuture<MqttMessage>> receiveFutures = Stream.generate(CompletableFuture<MqttMessage>::new) .limit(size) .collect(Collectors.toList()); Iterator<CompletableFuture<MqttMessage>> resultItr = receiveFutures.iterator(); client.subscribe(address, qos, (t, m) -> { assertThat("Unexpected message", resultItr.hasNext(), is(true)); log.debug("Received expected message: {}, Topic: {}", m, t); resultItr.next().complete(m); }); return receiveFutures; }
Example #2
Source File: MqttUtils.java From enmasse with Apache License 2.0 | 5 votes |
public static List<CompletableFuture<Void>> publish(IMqttClient client, String address, List<MqttMessage> messages) throws MqttException { List<CompletableFuture<Void>> futures = Stream.generate(CompletableFuture<Void>::new) .limit(messages.size()) .collect(Collectors.toList()); Iterator<CompletableFuture<Void>> resultItr = futures.iterator(); client.setCallback((MqttDeliveryCompleteCallback) token -> resultItr.next().complete(null)); for (MqttMessage message : messages) { client.publish(address, message); } return futures; }
Example #3
Source File: MqttClientFactory.java From enmasse with Apache License 2.0 | 4 votes |
public IMqttClient create() throws Exception { setSslContext(); return MqttClientFactory.create(MqttClient::new, DelegatingMqttClient::new, endpoint, options, clientId); }
Example #4
Source File: EngineTemperatureSensor.java From tutorials with MIT License | 4 votes |
public EngineTemperatureSensor(IMqttClient client) { this.client = client; }
Example #5
Source File: TestPublishMQTT.java From nifi with Apache License 2.0 | 4 votes |
@Override public IMqttClient createMqttClient(String broker, String clientID, MemoryPersistence persistence) throws MqttException { mqttTestClient = new MqttTestClient(broker, clientID, MqttTestClient.ConnectType.Publisher); return mqttTestClient; }
Example #6
Source File: TestConsumeMqttCommon.java From nifi with Apache License 2.0 | 4 votes |
private static boolean isConnected(AbstractMQTTProcessor processor) throws NoSuchFieldException, IllegalAccessException { Field f = AbstractMQTTProcessor.class.getDeclaredField("mqttClient"); f.setAccessible(true); IMqttClient mqttClient = (IMqttClient) f.get(processor); return mqttClient.isConnected(); }
Example #7
Source File: TestConsumeMQTT.java From nifi with Apache License 2.0 | 4 votes |
@Override public IMqttClient createMqttClient(String broker, String clientID, MemoryPersistence persistence) throws MqttException { mqttTestClient = new MqttTestClient(broker, clientID, MqttTestClient.ConnectType.Subscriber); return mqttTestClient; }
Example #8
Source File: AbstractMQTTProcessor.java From nifi with Apache License 2.0 | 4 votes |
protected IMqttClient createMqttClient(String broker, String clientID, MemoryPersistence persistence) throws MqttException { return new MqttClient(broker, clientID, persistence); }
Example #9
Source File: MqttClientFactory.java From enmasse with Apache License 2.0 | 4 votes |
public DelegatingMqttClient(IMqttClient mqttClient, MqttConnectOptions options) { this.mqttClient = mqttClient; this.options = options; }
Example #10
Source File: AbstractMQTTProcessor.java From localization_nifi with Apache License 2.0 | 4 votes |
protected IMqttClient getMqttClient(String broker, String clientID, MemoryPersistence persistence) throws MqttException { return new MqttClient(broker, clientID, persistence); }
Example #11
Source File: MqttClientFactory.java From enmasse with Apache License 2.0 | 4 votes |
public IMqttClient create() throws Exception { return new Builder().create(); }
Example #12
Source File: IoTProjectTestContext.java From enmasse with Apache License 2.0 | 4 votes |
public void setMqttAdapterClient(IMqttClient mqttAdapterClient) { this.mqttAdapterClient = mqttAdapterClient; }
Example #13
Source File: IoTProjectTestContext.java From enmasse with Apache License 2.0 | 4 votes |
public IMqttClient getMqttAdapterClient() { return mqttAdapterClient; }
Example #14
Source File: TestPublishMQTT.java From localization_nifi with Apache License 2.0 | 4 votes |
@Override public IMqttClient getMqttClient(String broker, String clientID, MemoryPersistence persistence) throws MqttException { mqttTestClient = new MqttTestClient(broker, clientID, MqttTestClient.ConnectType.Publisher); return mqttTestClient; }
Example #15
Source File: TestConsumeMqttCommon.java From localization_nifi with Apache License 2.0 | 4 votes |
private static boolean isConnected(AbstractMQTTProcessor processor) throws NoSuchFieldException, IllegalAccessException { Field f = AbstractMQTTProcessor.class.getDeclaredField("mqttClient"); f.setAccessible(true); IMqttClient mqttClient = (IMqttClient) f.get(processor); return mqttClient.isConnected(); }
Example #16
Source File: TestConsumeMQTT.java From localization_nifi with Apache License 2.0 | 4 votes |
@Override public IMqttClient getMqttClient(String broker, String clientID, MemoryPersistence persistence) throws MqttException { mqttTestClient = new MqttTestClient(broker, clientID, MqttTestClient.ConnectType.Subscriber); return mqttTestClient; }
Example #17
Source File: MqttV3Receiver.java From Sparkplug with Eclipse Public License 1.0 | 3 votes |
/** * @param mqttClient * @param reportStream */ public MqttV3Receiver(IMqttClient mqttClient, PrintStream reportStream) { this.reportStream = reportStream; connected = true; clientId = mqttClient.getClientId(); }