Interface ProducerBuilder
Producer
.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Routing configuration for super streams (partitioned streams). -
Method Summary
Modifier and TypeMethodDescriptionbatchPublishingDelay
(Duration batchPublishingDelay) Period to send a batch of messages.batchSize
(int batchSize) The maximum number of messages to accumulate before sending them to the broker.build()
Create theProducer
instance.compression
(Compression compression) Compression algorithm to use to compress a batch of sub-entries.confirmTimeout
(Duration timeout) Time before the client calls the confirm callback to signal outstanding unconfirmed messages timed out.enqueueTimeout
(Duration timeout) Time before enqueueing of a message fail when the maximum number of unconfirmed is reached.filterValue
(Function<Message, String> filterValueExtractor) Logic to extract a filter value from a message.maxUnconfirmedMessages
(int maxUnconfirmedMessages) The maximum number of unconfirmed outbound messages.The logical name of the producer.retryOnRecovery
(boolean retryOnRecovery) Whether to republish unconfirmed messages after recovery.Configure the routing for super streams (partitioned streams).The stream to send messages to.subEntrySize
(int subEntrySize) The number of messages to put in a sub-entry of a publish frame.superStream
(String superStream) The super stream to send messages to.
-
Method Details
-
name
The logical name of the producer.Set a value to enable de-duplication.
- Parameters:
name
-- Returns:
- this builder instance
-
stream
The stream to send messages to.- Parameters:
stream
-- Returns:
- this builder instance
-
superStream
The super stream to send messages to.This is an experimental API, subject to change.
- Parameters:
superStream
-- Returns:
- this builder instance
- See Also:
-
subEntrySize
The number of messages to put in a sub-entry of a publish frame.The default is 1 (no sub-entry batching).
- Parameters:
subEntrySize
-- Returns:
- this builder instance
-
compression
Compression algorithm to use to compress a batch of sub-entries.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.
- Parameters:
compression
-- Returns:
- this builder instance
- See Also:
-
batchSize
The maximum number of messages to accumulate before sending them to the broker.Default is 100.
- Parameters:
batchSize
-- Returns:
- this builder instance
-
batchPublishingDelay
Period to send a batch of messages.Default is 100 ms.
- Parameters:
batchPublishingDelay
-- Returns:
- this builder instance
-
maxUnconfirmedMessages
The maximum number of unconfirmed outbound messages.Producer.send(Message, ConfirmationHandler)
will start blocking when the limit is reached.Default is 10,000.
- Parameters:
maxUnconfirmedMessages
-- Returns:
- this builder instance
-
confirmTimeout
Time before the client calls the confirm callback to signal outstanding unconfirmed messages timed out.Default is 30 seconds.
- Parameters:
timeout
-- Returns:
- this builder instance
-
enqueueTimeout
Time before enqueueing of a message fail when the maximum number of unconfirmed is reached.Default is 10 seconds.
Set the value to
Duration.ZERO
if there should be no timeout.- Parameters:
timeout
-- Returns:
- this builder instance
-
retryOnRecovery
Whether to republish unconfirmed messages after recovery.Default is
true
(unconfirmed messages are republished after recovery).Set to
false
to not republish unconfirmed messages and get a negativeConfirmationStatus
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.- Parameters:
retryOnRecovery
- retry flag- Returns:
- this builder instance
- Since:
- 0.19.0
-
filterValue
Logic to extract a filter value from a message.RabbitMQ 3.13 or more is required.
- Parameters:
filterValueExtractor
-- Returns:
- this builder instance
-
build
Producer build()Create theProducer
instance.- Returns:
- the configured producer
-
routing
Configure the routing for super streams (partitioned streams).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 customRoutingStrategy
is set withrouting(Function)
.- Parameters:
routingKeyExtractor
- the logic to extract a routing key from a message- Returns:
- the routing configuration instance
- See Also:
-