List of usage examples for io.netty.handler.codec.mqtt MqttQoS value
int value
To view the source code for io.netty.handler.codec.mqtt MqttQoS value.
Click Source Link
From source file:io.crate.mqtt.protocol.MqttProcessor.java
public void handlePublish(Channel channel, MqttPublishMessage msg) { final MqttQoS qos = msg.fixedHeader().qosLevel(); String clientId = NettyUtils.clientID(channel); switch (qos) { case AT_LEAST_ONCE: SendPubAckCallback ackCallback = new SendPubAckCallback(channel, msg.variableHeader().packetId(), msg.fixedHeader().isDup()); ingestService.doInsert(clientId, msg, ackCallback); break;/*from w ww . j a v a 2 s .co m*/ default: String message = String.format(Locale.ENGLISH, "QoS %s (%s) is not supported.", qos.value(), qos.name()); throw new UnsupportedOperationException(message); } }
From source file:io.moquette.spi.impl.AbstractProtocolProcessorCommonUtils.java
License:Open Source License
protected void subscribe(EmbeddedChannel channel, String topic, MqttQoS desiredQos) { MqttSubscribeMessage subscribe = MqttMessageBuilders.subscribe().addSubscription(desiredQos, topic) .messageId(1).build();//from w w w . j a v a 2 s. com this.m_processor.processSubscribe(channel, subscribe); MqttSubAckMessage subAck = channel.readOutbound(); assertEquals(desiredQos.value(), (int) subAck.payload().grantedQoSLevels().get(0)); final String clientId = NettyUtils.clientID(channel); Subscription expectedSubscription = new Subscription(clientId, new Topic(topic), desiredQos); verifySubscriptionExists(m_sessionStore, expectedSubscription); }
From source file:io.vertx.mqtt.test.client.MqttClientSubscribeTest.java
License:Apache License
private void subscribeAndReceive(TestContext context, MqttQoS qos) { Async async = context.async();//from w w w .j a v a2 s. c om MqttClient client = MqttClient.create(Vertx.vertx()); client.publishHandler(publish -> { assertTrue(publish.qosLevel() == qos); log.info("Just received message on [" + publish.topicName() + "] payload [" + publish.payload().toString(Charset.defaultCharset()) + "] with QoS [" + publish.qosLevel() + "]"); client.disconnect(); async.countDown(); }); client.connect(MqttClientOptions.DEFAULT_PORT, TestUtil.BROKER_ADDRESS, ar -> { assertTrue(ar.succeeded()); client.subscribe(MQTT_TOPIC, qos.value()); client.publish(MQTT_TOPIC, Buffer.buffer(MQTT_MESSAGE.getBytes()), qos, false, false); }); async.await(); }
From source file:io.vertx.mqtt.test.client.MqttClientSubscribeTest.java
License:Apache License
private void subscribe(TestContext context, MqttQoS qos) { this.messageId = 0; Async async = context.async();//from ww w . j ava 2 s . co m MqttClient client = MqttClient.create(Vertx.vertx()); client.subscribeCompletionHandler(suback -> { assertTrue(suback.messageId() == messageId); assertTrue(suback.grantedQoSLevels().contains(qos.value())); log.info("subscribing complete for message id = " + suback.messageId() + " with QoS " + suback.grantedQoSLevels()); client.disconnect(); async.countDown(); }); client.connect(MqttClientOptions.DEFAULT_PORT, TestUtil.BROKER_ADDRESS, ar -> { assertTrue(ar.succeeded()); client.subscribe(MQTT_TOPIC, qos.value(), done -> { assertTrue(done.succeeded()); messageId = done.result(); log.info("subscribing on [" + MQTT_TOPIC + "] with QoS [" + qos.value() + "] message id = " + messageId); }); }); async.await(); }
From source file:io.vertx.mqtt.test.client.MqttClientUnsubscribeTest.java
License:Apache License
private void unsubscribe(TestContext context, MqttQoS qos) { this.messageId = 0; Async async = context.async();/*w w w. j av a 2s. c o m*/ MqttClient client = MqttClient.create(Vertx.vertx()); client.unsubscribeCompletionHandler(unsubackid -> { assertTrue(unsubackid == messageId); log.info("unsubscribing complete for message id = " + unsubackid); client.disconnect(); async.countDown(); }); client.subscribeCompletionHandler(suback -> { assertTrue(suback.messageId() == messageId); assertTrue(suback.grantedQoSLevels().contains(qos.value())); log.info("subscribing complete for message id = " + suback.messageId() + " with QoS " + suback.grantedQoSLevels()); client.unsubscribe(MQTT_TOPIC, ar2 -> { assertTrue(ar2.succeeded()); messageId = ar2.result(); log.info("unsubscribing on [" + MQTT_TOPIC + "] message id = " + messageId); }); }); client.connect(MqttClientOptions.DEFAULT_PORT, TestUtil.BROKER_ADDRESS, ar -> { assertTrue(ar.succeeded()); client.subscribe(MQTT_TOPIC, qos.value(), ar1 -> { assertTrue(ar1.succeeded()); messageId = ar1.result(); log.info("subscribing on [" + MQTT_TOPIC + "] with QoS [" + qos.value() + "] message id = " + messageId); }); }); async.await(); }
From source file:net.anyflow.lannister.topic.Topic.java
License:Apache License
private static MqttQoS adjustQoS(MqttQoS subscriptionQos, MqttQoS publishQos) { return subscriptionQos.value() <= publishQos.value() ? subscriptionQos : publishQos; }
From source file:org.thingsboard.server.transport.mqtt.MqttTransportHandler.java
License:Apache License
private static int getMinSupportedQos(MqttQoS reqQoS) { return Math.min(reqQoS.value(), MAX_SUPPORTED_QOS_LVL.value()); }