Package org.acemq.amqp.core
Class OrderedQueueBuilder<T>
java.lang.Object
org.acemq.amqp.core.OrderedQueueBuilder<T>
- Type Parameters:
T- payload type
Says how a stream of messages is partitioned, and then declares it.
OrderedQueue<Order> orders = mq.ordered("orders", Order.class)
.partitions(8)
.keyedBy(Order::customerId)
.onFailure(OrderedQueue.OnFailure.RETRY_IN_PLACE, 3, Duration.ofSeconds(2))
.declare();
The key is required and has no sensible default. A partitioned queue with no key is an ordinary queue with extra steps.
-
Method Summary
Modifier and TypeMethodDescriptiondeclare()Creates the exchange, the partition queues and the bindings.onFailure(OrderedQueue.OnFailure onFailure) onFailure(OrderedQueue.OnFailure onFailure, int attempts, Duration delay) partitions(int partitions) prefetch(int prefetch) toString()
-
Method Details
-
partitions
- Parameters:
partitions- how many queues to spread keys across. This is the ceiling on parallelism and cannot be changed later without draining first, because the partition a key belongs to is a function of the count- Returns:
- a builder with that many partitions
-
keyedBy
- Parameters:
key- what decides the sequence a message belongs to — a customer, an account, an aggregate identifier. Messages sharing one are handled in the order they were sent- Returns:
- a builder using it
-
prefetch
- Parameters:
prefetch- how many messages each partition's consumer may hold. Safe for ordering at any value, because one consumer dispatches serially- Returns:
- a builder with that prefetch
-
onFailure
- Parameters:
onFailure- what a failing handler does to the sequence- Returns:
- a builder with that policy
-
onFailure
public OrderedQueueBuilder<T> onFailure(OrderedQueue.OnFailure onFailure, int attempts, Duration delay) - Parameters:
onFailure- what a failing handler does to the sequenceattempts- how many times to try, when the policy retriesdelay- how long to wait between attempts, during which the partition is stalled- Returns:
- a builder with that policy
-
declare
Creates the exchange, the partition queues and the bindings.- Returns:
- the queue, ready to publish to and consume from
-
toString
-