Class Topology.Builder
- Enclosing class:
Topology
Topology.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()classicQueue(String name, Map<String, Object> arguments) classicQueueWithDeadLetter(String name, Map<String, Object> arguments) A classic queue that dead-letters, with arguments of its own.A durable quorum queue, which is the default everywhere in this library.queueWithDeadLetter(String name) A durable quorum queue that dead-letters, together with the two queues its dead letters end up in and the exchange they are reached through.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
exchange
- Parameters:
name- exchange nametype-direct,topic,fanoutorheaders- Returns:
- this builder
-
queue
A durable quorum queue, which is the default everywhere in this library.- Parameters:
name- queue name- Returns:
- this builder
-
classicQueue
- Parameters:
name- queue namearguments- broker-specific arguments- Returns:
- this builder
-
queueWithDeadLetter
A durable quorum queue that dead-letters, together with the two queues its dead letters end up in and the exchange they are reached through.The queue is declared with
x-dead-letter-exchangeset toTopology.DEAD_LETTER_EXCHANGEandx-dead-letter-routing-keyset to{name}.dlq, and{name}.dlqand{name}.parkedare declared and bound to that exchange on their own names. Several declarations as one call, because they are only correct together: a queue whose dead-letter exchange nothing declares, or one with no queue bound to it, throws messages away exactly as if dead-lettering had never been configured, and nothing reports it.The routing key matters as much as the exchange. A message the broker dead-letters keeps the routing key it arrived under, so without it a message published as
order.placedwould reachacemq.dlxunder that key, match no binding, and be dropped — the silent loss this method exists to prevent.This is a backstop, not a replacement for what the consumer already does. A handler that fails is dead-lettered by this library itself: republished to
{name}.dlqwith the reason recorded on the envelope, and only then acknowledged, which is how the reason survives at all — the broker's own dead-lettering carries anx-deathheader and no idea why the message failed. Both paths stay. The broker-side route catches what the library never sees: a message expiring under the source queue's ownx-message-ttl, an overflow underx-max-length, a reject from some other consumer of the same queue. Without these arguments those messages vanish; with them they land in the same queue an operator is already watching. Neither path is dead code.Neither
{name}.dlqnor{name}.parkeddead-letters in turn. A dead-letter queue that dead-letters is a loop, and a loop is how a poison message becomes an outage.- Parameters:
name- queue name- Returns:
- this builder
-
classicQueueWithDeadLetter
A classic queue that dead-letters, with arguments of its own.The same arrangement as
queueWithDeadLetter(String), for a queue that needs a time-to-live, a length limit or any other argument alongside it.- Parameters:
name- queue namearguments- broker-specific arguments, which must not set either dead-letter argument- Returns:
- this builder
- Throws:
IllegalArgumentException- when the arguments already setx-dead-letter-exchangeorx-dead-letter-routing-key
-
bind
- Parameters:
queue- queue to bindexchange- exchange to bind it toroutingKey- routing key or pattern- Returns:
- this builder
-
build
-