/** * Sends an AMQP 1.0 message to the endpoint configured for this client. * <p> * This default implementation simply returns the result of {@link #send(Message)}. * * @param message The message to send. * @param context The currently active OpenTracing span. An implementation * should use this as the parent for any span it creates for tracing * the execution of this operation. * @return A future indicating the outcome of the operation. * <p> * The future will be succeeded if the message has been sent to the endpoint. * The delivery contained in the future represents the delivery state at the time * the future has been succeeded, i.e. for telemetry data it will be locally * <em>unsettled</em> without any outcome yet. For events it will be locally * and remotely <em>settled</em> and will contain the <em>accepted</em> outcome. * <p> * The future will be failed with a {@link ServerErrorException} if the message * could not be sent due to a lack of credit. * If an event is sent which cannot be processed by the peer the future will * be failed with either a {@code ServerErrorException} or a {@link ClientErrorException} * depending on the reason for the failure to process the message. * @throws NullPointerException if message is {@code null}. */ default Future<ProtonDelivery> send(Message message, SpanContext context) { return send(message); }
/** * Sends an AMQP 1.0 message to the peer and waits for the disposition indicating * the outcome of the transfer. * <p> * This default implementation simply returns the result of {@link #sendAndWaitForOutcome(Message)}. * * @param message The message to send. * @param context The currently active OpenTracing span. An implementation * should use this as the parent for any span it creates for tracing * the execution of this operation. * @return A future indicating the outcome of the operation. * <p> * The future will be succeeded if the message has been accepted (and settled) * by the peer. * <p> * The future will be failed with a {@link ServerErrorException} if the message * could not be sent due to a lack of credit. * If an event is sent which cannot be processed by the peer the future will * be failed with either a {@code ServerErrorException} or a {@link ClientErrorException} * depending on the reason for the failure to process the message. * @throws NullPointerException if message is {@code null}. */ default Future<ProtonDelivery> sendAndWaitForOutcome(Message message, SpanContext context) { return sendAndWaitForOutcome(message); }
sender.isRegistrationAssertionRequired(), context.getEndpoint(), context.getMessageContentType(), context.getMessagePayload(), tokenFuture.result(), null); return sender.send(downstreamMessage, currentSpan.context()); } else { return sender.sendAndWaitForOutcome(downstreamMessage, currentSpan.context());
final Message msg = newMessage( ResourceIdentifier.from(EventConstants.EVENT_ENDPOINT, tenant, deviceId), senderTracker.result().isRegistrationAssertionRequired(), EventConstants.EVENT_ENDPOINT, EventConstants.CONTENT_TYPE_EMPTY_NOTIFICATION, tokenTracker.result(), ttd); return sender.sendAndWaitForOutcome(msg, context); } else {
LOGGER.trace("sending message for device [{}]; credit: {}", deviceId, senderFuture.result().getCredit()); if (LOGGER.isDebugEnabled() && senderFuture.result().getCredit() == 1) { LOGGER.debug("only 1 credit left, will wait for new credit after having sent the message"); sendResultFuture = senderFuture.result().send( deviceId, properties, sendResultFuture = senderFuture.result().send( deviceId, properties,
private Future<Device> createLinks(final Device authenticatedDevice, final Span currentSpan) { final Future<MessageSender> telemetrySender = getTelemetrySender(authenticatedDevice.getTenantId()); final Future<MessageSender> eventSender = getEventSender(authenticatedDevice.getTenantId()); return CompositeFuture .all(telemetrySender, eventSender) .compose(ok -> { currentSpan.log("opened downstream links"); LOG.debug( "providently opened downstream links [credit telemetry: {}, credit event: {}] for tenant [{}]", telemetrySender.result().getCredit(), eventSender.result().getCredit(), authenticatedDevice.getTenantId()); return Future.succeededFuture(authenticatedDevice); }); }
final Message downstreamMessage = newMessage( ResourceIdentifier.from(endpointName, device.getTenantId(), device.getDeviceId()), sender.isRegistrationAssertionRequired(), "/" + exchange.getRequestOptions().getUriPathString(), contentType, if (waitForOutcome) { return sender.sendAndWaitForOutcome(downstreamMessage); } else { return sender.send(downstreamMessage);
final Message msg = newMessage( ResourceIdentifier.from(EventConstants.EVENT_ENDPOINT, tenant, deviceId), senderTracker.result().isRegistrationAssertionRequired(), EventConstants.EVENT_ENDPOINT, EventConstants.CONTENT_TYPE_EMPTY_NOTIFICATION, tokenTracker.result(), ttd); return sender.sendAndWaitForOutcome(msg, context); } else {
private Future<Device> createLinks(final Device authenticatedDevice, final Span currentSpan) { final Future<MessageSender> telemetrySender = getTelemetrySender(authenticatedDevice.getTenantId()); final Future<MessageSender> eventSender = getEventSender(authenticatedDevice.getTenantId()); return CompositeFuture .all(telemetrySender, eventSender) .compose(ok -> { currentSpan.log("opened downstream links"); LOG.debug( "providently opened downstream links [credit telemetry: {}, credit event: {}] for tenant [{}]", telemetrySender.result().getCredit(), eventSender.result().getCredit(), authenticatedDevice.getTenantId()); return Future.succeededFuture(authenticatedDevice); }); }
final Message downstreamMessage = newMessage( ResourceIdentifier.from(endpointName, tenant, deviceId), sender.isRegistrationAssertionRequired(), ctx.message().topicName(), ctx.contentType(), return sender.sendAndWaitForOutcome(downstreamMessage, currentSpan.context()); } else { return sender.send(downstreamMessage, currentSpan.context());
); messageSender.send(HonoExampleConstants.DEVICE_ID, null, "myMessage" + value, "text/plain", token, capacityAvail -> { capacityAvailableFuture.complete(null);
final Message downstreamMessage = newMessage( ResourceIdentifier.from(endpointName, tenant, deviceId), sender.isRegistrationAssertionRequired(), ctx.message().topicName(), ctx.contentType(), return sender.sendAndWaitForOutcome(downstreamMessage, currentSpan.context()); } else { return sender.send(downstreamMessage, currentSpan.context());
return senderFuture.result().send( deviceId, payload.encode().getBytes(StandardCharsets.UTF_8),
final Message downstreamMessage = newMessage( ResourceIdentifier.from(endpointName, tenant, deviceId), sender.isRegistrationAssertionRequired(), ctx.request().uri(), contentType, sender.send(downstreamMessage, currentSpan.context()), responseReady) .map(s -> (Void) null); currentSpan.setTag(Constants.HEADER_QOS_LEVEL, qosHeaderValue); return CompositeFuture.all( sender.sendAndWaitForOutcome(downstreamMessage, currentSpan.context()), responseReady) .map(s -> (Void) null);
return senderFuture.result().send( deviceId, payload.encode().getBytes(StandardCharsets.UTF_8),
final Message downstreamMessage = newMessage( ResourceIdentifier.from(endpointName, tenant, deviceId), sender.isRegistrationAssertionRequired(), ctx.request().uri(), contentType, sender.send(downstreamMessage, currentSpan.context()), responseReady) .map(s -> (Void) null); currentSpan.setTag(Constants.HEADER_QOS_LEVEL, qosHeaderValue); return CompositeFuture.all( sender.sendAndWaitForOutcome(downstreamMessage, currentSpan.context()), responseReady) .map(s -> (Void) null);