public interface ProducerBuilder
Producer.| Modifier and Type | Interface and Description |
|---|---|
static interface |
ProducerBuilder.RoutingConfiguration
Routing configuration for super streams (partitioned streams).
|
| Modifier and Type | Method and Description |
|---|---|
ProducerBuilder |
batchPublishingDelay(Duration batchPublishingDelay)
Period to send a batch of messages.
|
ProducerBuilder |
batchSize(int batchSize)
The maximum number of messages to accumulate before sending them to the broker.
|
Producer |
build()
Create the
Producer instance. |
ProducerBuilder |
compression(Compression compression)
Compression algorithm to use to compress a batch of sub-entries.
|
ProducerBuilder |
confirmTimeout(Duration timeout)
Time before the client calls the confirm callback to signal outstanding unconfirmed messages
timed out.
|
ProducerBuilder |
dynamicBatch(boolean dynamicBatch)
Adapt batch size depending on ingress rate.
|
ProducerBuilder |
enqueueTimeout(Duration timeout)
Time before enqueueing of a message fail when the maximum number of unconfirmed is reached.
|
ProducerBuilder |
filterValue(Function<Message,String> filterValueExtractor)
Logic to extract a filter value from a message.
|
ProducerBuilder |
maxUnconfirmedMessages(int maxUnconfirmedMessages)
The maximum number of unconfirmed outbound messages.
|
ProducerBuilder |
name(String name)
The logical name of the producer.
|
ProducerBuilder |
retryOnRecovery(boolean retryOnRecovery)
Whether to republish unconfirmed messages after recovery.
|
ProducerBuilder.RoutingConfiguration |
routing(Function<Message,String> routingKeyExtractor)
Configure the routing for super streams (partitioned streams).
|
ProducerBuilder |
stream(String stream)
The stream to send messages to.
|
ProducerBuilder |
subEntrySize(int subEntrySize)
The number of messages to put in a sub-entry of a publish frame.
|
ProducerBuilder |
superStream(String superStream)
The super stream to send messages to.
|
ProducerBuilder name(String name)
Set a value to enable de-duplication.
name - ProducerBuilder stream(String stream)
stream - ProducerBuilder superStream(String superStream)
This is an experimental API, subject to change.
superStream - routing(Function)ProducerBuilder subEntrySize(int subEntrySize)
The default is 1 (no sub-entry batching).
subEntrySize - ProducerBuilder compression(Compression compression)
Compression can take advantage of similarity in messages to significantly reduce the size of the sub-entry batch. This translates to less bandwidth and storage used, at the cost of more CPU usage to compress and decompress on the client side. Note the server is not involved in the compression/decompression process.
Default is no compression.
compression - CompressionProducerBuilder batchSize(int batchSize)
Default is 100.
batchSize - ProducerBuilder batchPublishingDelay(Duration batchPublishingDelay)
Default is 100 ms.
batchPublishingDelay - ProducerBuilder dynamicBatch(boolean dynamicBatch)
A dynamic-batch approach improves latency for low ingress rates. It can be counterproductive for sustained high ingress rates.
Set this flag to true if you want as little delay as possible before calling
Producer.send(Message, ConfirmationHandler) and the message being sent to the broker.
Set this flag to false if latency is not critical for your use case and you
want the highest throughput possible for both publishing and consuming.
Dynamic batch is not activated by default (dynamicBatch = false).
Dynamic batch is experimental.
dynamicBatch - ProducerBuilder maxUnconfirmedMessages(int maxUnconfirmedMessages)
Producer.send(Message, ConfirmationHandler) will start blocking when the limit is
reached.
Default is 10,000.
maxUnconfirmedMessages - ProducerBuilder confirmTimeout(Duration timeout)
Default is 30 seconds.
timeout - ProducerBuilder enqueueTimeout(Duration timeout)
Default is 10 seconds.
Set the value to Duration.ZERO if there should be no timeout.
timeout - ProducerBuilder retryOnRecovery(boolean retryOnRecovery)
Default is true (unconfirmed messages are republished after recovery).
Set to false to not republish unconfirmed messages and get a negative ConfirmationStatus for unconfirmed messages.
Note setting this flag to false translates to at-most-once semantics, that is
published messages may be lost, unless the publishing application retries publishing them.
retryOnRecovery - retry flagProducerBuilder filterValue(Function<Message,String> filterValueExtractor)
RabbitMQ 3.13 or more is required.
filterValueExtractor - ProducerBuilder.RoutingConfiguration routing(Function<Message,String> routingKeyExtractor)
This is an experimental API, subject to change.
The to-be-created producer will be a composite producer when this method is called. It will use the routing configuration to find out where a message should be routed. The application developer must provide the logic to extract a "routing key" from a message, which will decide the destination(s) of the message.
The default routing strategy hashes the routing key to choose the stream (partition) to send the message to.
Note the routing key extraction logic is required only when the built-in routing strategies
are used. It can set to null when a custom RoutingStrategy is set with
routing(Function).
routingKeyExtractor - the logic to extract a routing key from a messageProducerBuilder.RoutingConfigurationCopyright © 2024 Broadcom Inc. and/or its subsidiaries. All rights reserved.