if (sender.getQoS().equals(ProtonQoS.AT_MOST_ONCE)) { sender.send(message); numSent.incrementAndGet();
items.put(Tags.MESSAGE_BUS_DESTINATION.getKey(), sender.getRemoteTarget().getAddress()); items.put(TracingHelper.TAG_QOS.getKey(), sender.getQoS().name()); items.put(TracingHelper.TAG_CREDIT.getKey(), sender.getCredit()); commandContext.getCurrentSpan().log(items);
details.put(TracingHelper.TAG_MESSAGE_ID.getKey(), messageId); details.put(TracingHelper.TAG_CREDIT.getKey(), sender.getCredit()); details.put(TracingHelper.TAG_QOS.getKey(), sender.getQoS().toString()); currentSpan.log(details);
private void sendMessage(final Message msg) { ByteBuffer b = ByteBuffer.allocate(4); b.putInt(count.getAndIncrement()); b.flip(); LOG.trace("sending message [id: {}] to peer", msg.getMessageId()); if (ProtonQoS.AT_MOST_ONCE.equals(sender.getQoS())) { sender.send(b.array(), msg); sentHandler.handle(null); } else { sender.send(b.array(), msg, res -> { if (Accepted.class.isInstance(res.getRemoteState())) { LOG.trace("message [id: {}, remotelySettled: {}] has been accepted by peer", msg.getMessageId(), res.remotelySettled()); res.settle(); if (sentHandler != null) { sentHandler.handle(null); } } else { LOG.warn("message [id: {}] has not been accepted by peer: {}", msg.getMessageId(), res.getRemoteState()); } }); } } }
details.put(TracingHelper.TAG_MESSAGE_ID.getKey(), messageId); details.put(TracingHelper.TAG_CREDIT.getKey(), sender.getCredit()); details.put(TracingHelper.TAG_QOS.getKey(), sender.getQoS().toString()); currentSpan.log(details);
@Override public final void onLinkAttach(final ProtonConnection con, final ProtonSender sender, final ResourceIdentifier targetResource) { if (ProtonQoS.AT_LEAST_ONCE.equals(sender.getRemoteQoS())) { final HonoUser user = Constants.getClientPrincipal(con); sender.setQoS(ProtonQoS.AT_LEAST_ONCE).open(); logger.debug("transferring token to client..."); final Message tokenMsg = ProtonHelper.message(user.getToken()); MessageHelper.addProperty(tokenMsg, AuthenticationConstants.APPLICATION_PROPERTY_TYPE, AuthenticationConstants.TYPE_AMQP_JWT); sender.send(tokenMsg, disposition -> { if (disposition.remotelySettled()) { logger.debug("successfully transferred auth token to client"); } else { logger.debug("failed to transfer auth token to client"); } sender.close(); }); } else { onLinkDetach(sender, ProtonHelper.condition(AmqpError.INVALID_FIELD, "supports AT_LEAST_ONCE delivery mode only")); } }
details.put(TracingHelper.TAG_QOS.getKey(), sender.getQoS().toString()); currentSpan.log(details); final TriTuple<Handler<AsyncResult<R>>, Object, Span> handler = TriTuple.of(resultHandler, cacheKey, currentSpan);
if (ProtonQoS.AT_MOST_ONCE.equals(receiver.getRemoteQoS())) { logger.debug("client wants to use unsupported AT MOST ONCE delivery mode for endpoint [{}], closing link ...", getName()); receiver.setCondition(ProtonHelper.condition(AmqpError.PRECONDITION_FAILED.toString(), "endpoint requires AT_LEAST_ONCE QoS"));
if (ProtonQoS.AT_MOST_ONCE.equals(receiver.getRemoteQoS())) { logger.debug("client wants to use unsupported AT MOST ONCE delivery mode for endpoint [{}], closing link ...", getName()); receiver.setCondition(ProtonHelper.condition(AmqpError.PRECONDITION_FAILED.toString(), "endpoint requires AT_LEAST_ONCE QoS"));
@Override public void onLinkAttach(final ProtonReceiver receiver, final ResourceIdentifier targetAddress) { if (ProtonQoS.AT_MOST_ONCE.equals(receiver.getRemoteQoS())) { logger.debug("client wants to use AT MOST ONCE delivery mode for registration endpoint, this is not supported."); receiver.setCondition(condition(AmqpError.PRECONDITION_FAILED.toString(), "endpoint requires AT_LEAST_ONCE QoS")); receiver.close(); } else { logger.debug("establishing link for receiving registration messages from client [{}]", MessageHelper.getLinkName(receiver)); receiver .setQoS(ProtonQoS.AT_LEAST_ONCE) .setAutoAccept(true) // settle received messages if the handler succeeds .setPrefetch(20) .handler((delivery, message) -> { if (RegistrationMessageFilter.verify(targetAddress, message)) { try { processRequest(message); } catch (DecodeException e) { MessageHelper.rejected(delivery, AmqpError.DECODE_ERROR.toString(), "malformed payload"); } } else { MessageHelper.rejected(delivery, AmqpError.DECODE_ERROR.toString(), "malformed registration message"); // we close the link if the client sends a message that does not comply with the API spec onLinkDetach(receiver, condition(AmqpError.DECODE_ERROR.toString(), "invalid message received")); } }).closeHandler(clientDetached -> onLinkDetach(clientDetached.result())) .open(); } }
if (ProtonQoS.AT_MOST_ONCE.equals(receiver.getRemoteQoS())) {