Search in sources :

Example 6 with NettyWritable

use of org.apache.activemq.artemis.protocol.amqp.util.NettyWritable in project activemq-artemis by apache.

the class AMQPMessage method encodeProtonMessage.

private void encodeProtonMessage() {
    int estimated = Math.max(1500, data != null ? data.capacity() + 1000 : 0);
    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.heapBuffer(estimated);
    try {
        getProtonMessage().encode(new NettyWritable(buffer));
        byte[] bytes = new byte[buffer.writerIndex()];
        buffer.readBytes(bytes);
        this.data = Unpooled.wrappedBuffer(bytes);
    } finally {
        buffer.release();
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) NettyWritable(org.apache.activemq.artemis.protocol.amqp.util.NettyWritable)

Aggregations

NettyWritable (org.apache.activemq.artemis.protocol.amqp.util.NettyWritable)6 ByteBuf (io.netty.buffer.ByteBuf)5 Header (org.apache.qpid.proton.amqp.messaging.Header)3 AMQPMessage (org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage)2 ServerJMSMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage)2 Binary (org.apache.qpid.proton.amqp.Binary)2 Section (org.apache.qpid.proton.amqp.messaging.Section)2 ByteBuffer (java.nio.ByteBuffer)1 CharBuffer (java.nio.CharBuffer)1 CharacterCodingException (java.nio.charset.CharacterCodingException)1 Charset (java.nio.charset.Charset)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Destination (javax.jms.Destination)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ServerJMSStreamMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage)1 ActiveMQAMQPIllegalStateException (org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException)1