@Override public void serverSend( final Receiver receiver, final Delivery delivery, String address, int messageFormat, ByteBuf messageEncoded) throws Exception { EncodedMessage encodedMessage = new EncodedMessage( messageFormat, messageEncoded.array(), messageEncoded.arrayOffset(), messageEncoded.writerIndex()); ServerMessage message = manager.getConverter().inbound(encodedMessage); // use the address on the receiver if not null, if null let's hope it was set correctly on the // message if (address != null) { message.setAddress(new SimpleString(address)); } recoverContext(); try { serverSession.send(message, false); manager .getServer() .getStorageManager() .afterCompleteOperations( new IOCallback() { @Override public void done() { synchronized (connection.getLock()) { delivery.settle(); connection.flush(); } } @Override public void onError(int errorCode, String errorMessage) { synchronized (connection.getLock()) { receiver.setCondition( new ErrorCondition( AmqpError.ILLEGAL_STATE, errorCode + ":" + errorMessage)); connection.flush(); } } }); } finally { resetContext(); } }
@Override public ProtonJMessage encodeMessage(Object message, int deliveryCount) throws Exception { return (ProtonJMessage) manager.getConverter().outbound((ServerMessage) message, deliveryCount); }