public void request(
            final Message message,
            final OperationResult<Message, Exception> onResponse) {

        if (message == null) {
            throw new IllegalArgumentException("message cannot be null");
        }
        if (message.getMessageId() != null) {
            throw new IllegalArgumentException("message.getMessageId() should be null");
        }
        if (message.getReplyTo() != null) {
            throw new IllegalArgumentException("message.getReplyTo() should be null");
        }
        message.setMessageId("request" + UnsignedLong.valueOf(this.requestId.incrementAndGet()).toString());
        message.setReplyTo(this.replyTo);

        this.inflightRequests.put(message.getMessageId(), onResponse);

        sendLink.delivery(UUID.randomUUID().toString().replace("-", StringUtil.EMPTY).getBytes(UTF_8));
        final int payloadSize = AmqpUtil.getDataSerializedSize(message) + 512; // need buffer for headers

        final byte[] bytes = new byte[payloadSize];
        final int encodedSize = message.encode(bytes, 0, payloadSize);

        receiveLink.flow(1);
        sendLink.send(bytes, 0, encodedSize);
        sendLink.advance();
    }
public void request ( final Message message , final OperationResult < Message , Exception > onResponse ) { if ( message == null ) { throw new IllegalArgumentException ( "message cannot be null" ) ; } if ( message . getMessageId ( ) != null ) { throw new IllegalArgumentException ( "message.getMessageId() should be null" ) ; } if ( message . getReplyTo ( ) != null ) { throw new IllegalArgumentException ( "message.getReplyTo() should be null" ) ; } message . setMessageId ( "request" + UnsignedLong . valueOf ( this . requestId . incrementAndGet ( ) ) . toString ( ) ) ; message . setReplyTo ( this . replyTo ) ; this . inflightRequests . put ( message . getMessageId ( ) , onResponse ) ; sendLink . delivery ( UUID . randomUUID ( ) . toString ( ) . replace ( "-" , StringUtil . EMPTY ) . getBytes ( UTF_8 ) ) ; final int payloadSize = AmqpUtil . getDataSerializedSize ( message ) + 512 ; final byte [ ] bytes = new byte [ payloadSize ] ; final int encodedSize = message . encode ( bytes , 0 , payloadSize ) ; receiveLink . flow ( 1 ) ; sendLink . send ( bytes , 0 , encodedSize ) ; sendLink . advance ( ) ; }
& assumes that this is run on Opened Object