//presettle means we can ack the message on the proton side before we send it, i.e. for browsers
boolean preSettle = sender.getRemoteSenderSettleMode() == SenderSettleMode.SETTLED;
//we only need a tag if we are going to ack later
byte[] tag = preSettle ? new byte[0] : protonSession.getTag();
//encode the message
EncodedMessage encodedMessage = ProtonUtils.OUTBOUND.transform(message, deliveryCount);
//now handle the delivery
protonProtocolManager.handleDelivery(sender, tag, encodedMessage, message, connection, preSettle);
return encodedMessage.getLength();
}