Search in sources :

Example 6 with EncodedMessage

use of com.rabbitmq.stream.Codec.EncodedMessage in project rabbitmq-stream-java-client by rabbitmq.

the class Client method publishBatches.

public List<Long> publishBatches(byte publisherId, List<MessageBatch> messageBatches, OutboundEntityMappingCallback mappingCallback, ToLongFunction<Object> publishSequenceFunction) {
    List<Object> encodedMessageBatches = new ArrayList<>(messageBatches.size());
    for (MessageBatch batch : messageBatches) {
        EncodedMessageBatch encodedMessageBatch = createEncodedMessageBatch(batch.compression, batch.messages.size());
        for (Message message : batch.messages) {
            Codec.EncodedMessage encodedMessage = codec.encode(message);
            checkMessageFitsInFrame(encodedMessage);
            encodedMessageBatch.add(encodedMessage);
        }
        encodedMessageBatch.close();
        checkMessageBatchFitsInFrame(encodedMessageBatch);
        OriginalAndEncodedOutboundEntity wrapper = new OriginalAndEncodedOutboundEntity(batch, encodedMessageBatch);
        encodedMessageBatches.add(wrapper);
    }
    return publishInternal(this.channel, publisherId, encodedMessageBatches, new OriginalEncodedEntityOutboundEntityWriteCallback(mappingCallback, OUTBOUND_MESSAGE_BATCH_WRITE_CALLBACK), publishSequenceFunction);
}
Also used : Codec(com.rabbitmq.stream.Codec) CompressionCodec(com.rabbitmq.stream.compression.CompressionCodec) Message(com.rabbitmq.stream.Message) EncodedMessage(com.rabbitmq.stream.Codec.EncodedMessage) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) EncodedMessage(com.rabbitmq.stream.Codec.EncodedMessage)

Aggregations

EncodedMessage (com.rabbitmq.stream.Codec.EncodedMessage)6 ArrayList (java.util.ArrayList)6 Codec (com.rabbitmq.stream.Codec)5 Message (com.rabbitmq.stream.Message)5 CompressionCodec (com.rabbitmq.stream.compression.CompressionCodec)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 MessageBuilder (com.rabbitmq.stream.MessageBuilder)1 UnsignedByte (com.rabbitmq.stream.amqp.UnsignedByte)1 UnsignedInteger (com.rabbitmq.stream.amqp.UnsignedInteger)1 UnsignedLong (com.rabbitmq.stream.amqp.UnsignedLong)1 UnsignedShort (com.rabbitmq.stream.amqp.UnsignedShort)1 QpidProtonAmqpMessageWrapper (com.rabbitmq.stream.codec.QpidProtonCodec.QpidProtonAmqpMessageWrapper)1 CompressedEncodedMessageBatch (com.rabbitmq.stream.impl.Client.CompressedEncodedMessageBatch)1 EncodedMessageBatch (com.rabbitmq.stream.impl.Client.EncodedMessageBatch)1 ByteBuf (io.netty.buffer.ByteBuf)1 ByteBufAllocator (io.netty.buffer.ByteBufAllocator)1 ByteBufInputStream (io.netty.buffer.ByteBufInputStream)1 InputStream (java.io.InputStream)1