System.out.println("Just received message on [" + message.topicName() + "] payload [" + message.payload() + "] with QoS [" + message.qosLevel() + "]");
System.out.println("Just received message on [" + publish.topicName() + "] payload [" + publish.payload().toString(Charset.defaultCharset()) + "] with QoS [" + publish.qosLevel() + "]"); });
System.out.println("Just received message on [" + message.topicName() + "] payload [" + message.payload() + "] with QoS [" + message.qosLevel() + "]");
/** * @return Topic on which the message was published */ public String topicName() { if (cached_4 != null) { return cached_4; } String ret = delegate.topicName(); cached_4 = ret; return ret; }
/** * @return Topic on which the message was published */ public String topicName() { if (cached_4 != null) { return cached_4; } String ret = delegate.topicName(); cached_4 = ret; return ret; }
/** * @return Topic on which the message was published */ public String topicName() { if (cached_4 != null) { return cached_4; } String ret = delegate.topicName(); cached_4 = ret; return ret; }
/** * Creates a new context for a message and an endpoint. * * @param publishedMessage The published MQTT message. * @param deviceEndpoint The endpoint representing the device * that has published the message. * @param authenticatedDevice The authenticated device identity. * @throws NullPointerException if message or endpoint are {@code null}. */ public MqttContext( final MqttPublishMessage publishedMessage, final MqttEndpoint deviceEndpoint, final Device authenticatedDevice) { this.message = Objects.requireNonNull(publishedMessage); this.deviceEndpoint = Objects.requireNonNull(deviceEndpoint); this.authenticatedDevice = authenticatedDevice; ResourceIdentifier t = null; try { t = ResourceIdentifier.fromString(publishedMessage.topicName()); } catch (final Throwable e) { } this.topic = t; }
/** * {@inheritDoc} */ @Override protected Future<Void> onPublishedMessage(final MqttContext ctx) { return mapTopic(ctx) .recover(t -> { LOG.debug("discarding message [topic: {}] from device: {}", ctx.message().topicName(), t.getMessage()); return Future.failedFuture(t); }).compose(targetAddress -> uploadMessage(ctx, targetAddress, ctx.message())); }
/** * {@inheritDoc} */ @Override protected Future<Void> onPublishedMessage(final MqttContext ctx) { return mapTopic(ctx) .recover(t -> { LOG.debug("discarding message [topic: {}] from device: {}", ctx.message().topicName(), t.getMessage()); return Future.failedFuture(t); }).compose(targetAddress -> uploadMessage(ctx, targetAddress, ctx.message())); }
/** * {@inheritDoc} */ @Override protected Future<Void> onPublishedMessage(final MqttContext ctx) { return mapTopic(ctx) .compose(address -> checkAddress(ctx, address)) .compose(targetAddress -> uploadMessage(ctx, targetAddress, ctx.message())) .recover(t -> { LOG.debug("discarding message [topic: {}] from device: {}", ctx.message().topicName(), t.getMessage()); return Future.failedFuture(t); }); }
/** * {@inheritDoc} */ @Override protected Future<Void> onPublishedMessage(final MqttContext ctx) { return mapTopic(ctx) .compose(address -> checkAddress(ctx, address)) .compose(targetAddress -> uploadMessage(ctx, targetAddress, ctx.message())) .recover(t -> { LOG.debug("discarding message [topic: {}] from device: {}", ctx.message().topicName(), t.getMessage()); return Future.failedFuture(t); }); }
ResourceIdentifier t = null; try { t = ResourceIdentifier.fromString(publishedMessage.topicName()); if (t.getEndpoint().length() == 1) {
private void subscribeAndReceive(TestContext context, MqttQoS qos) { Async async = context.async(); 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(TestUtil.BROKER_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(); }
private void subscribeAndReceive(TestContext context, MqttQoS qos) { Async async = context.async(); 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(TestUtil.BROKER_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(); }
.ignoreActiveSpan() .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag(Tags.MESSAGE_BUS_DESTINATION.getKey(), context.message().topicName()) .withTag(TracingHelper.TAG_QOS.getKey(), qos.toString()) .withTag(Tags.COMPONENT.getKey(), getTypeName())
.ignoreActiveSpan() .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .withTag(Tags.MESSAGE_BUS_DESTINATION.getKey(), context.message().topicName()) .withTag(TracingHelper.TAG_QOS.getKey(), qos.toString()) .withTag(Tags.COMPONENT.getKey(), getTypeName())
@Override protected void endpointHandler(MqttEndpoint endpoint, TestContext context) { endpoint.publishHandler(message -> { log.info("Just received message on [" + message.topicName() + "] payload [" + message.payload().toString(Charset.defaultCharset()) + "] with QoS [" + message.qosLevel() + "]"); switch (message.qosLevel()) { case AT_LEAST_ONCE: endpoint.publishAcknowledge(message.messageId()); this.async.complete(); break; case EXACTLY_ONCE: endpoint.publishReceived(message.messageId()); break; case AT_MOST_ONCE: this.async.complete(); break; } }).publishReleaseHandler(messageId -> { endpoint.publishComplete(messageId); this.async.complete(); }); endpoint.accept(false); }
@Override protected void endpointHandler(MqttEndpoint endpoint, TestContext context) { endpoint.publishHandler(message -> { log.info("Just received message on [" + message.topicName() + "] payload [" + message.payload().toString(Charset.defaultCharset()) + "] with QoS [" + message.qosLevel() + "]"); switch (message.qosLevel()) { case AT_LEAST_ONCE: endpoint.publishAcknowledge(message.messageId()); this.async.complete(); break; case EXACTLY_ONCE: endpoint.publishReceived(message.messageId()); break; case AT_MOST_ONCE: this.async.complete(); break; } }).publishReleaseHandler(messageId -> { endpoint.publishComplete(messageId); this.async.complete(); }); endpoint.accept(false); }
log.info("Just received message on [" + message.topicName() + "] payload [" + message.payload().toString(Charset.defaultCharset()) + "] with QoS [" + message.qosLevel() + "]");
log.info("Just received message on [" + message.topicName() + "] payload [" + message.payload().toString(Charset.defaultCharset()) + "] with QoS [" + message.qosLevel() + "]");