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);
}
Aggregations