Class TopologyPlanner
Topology would change before changing it.
Declaring a topology blindly at start-up is the normal approach and it has a specific failure mode: AMQP forbids changing most queue arguments in place, so a queue that already exists with different settings does not quietly adapt. The declare fails, and on AMQP 0-9-1 it takes the channel with it. The failure therefore happens in production, at start-up, rather than in review, where the difference was visible all along.
Planning first turns that into something readable. The plan says what exists and what
would be created; ApplyMode.DRY_RUN prints it without touching anything, and
ApplyMode.VALIDATE refuses to start when the topology is not already there.
A queue that exists with settings the topology disagrees with is reported as
TopologyPlan.Kind.DRIFT rather than as present, and apply(org.acemq.amqp.api.Topology, org.acemq.amqp.api.ApplyMode) refuses to run
rather than failing partway through. AMQP has no way to read a queue's arguments back, so the
check is made by offering the declaration to the broker on a channel of its own and reading
its refusal — which names the argument and both values, and is therefore better than an
inspection API would have been.
What is still missing is the shadow-queue migration that resolves drift: creating the replacement, moving the messages, and swapping the bindings. That is deliberately absent rather than approximated, because the safe order depends on whether the queue can be drained first, which is not something a library can decide.
-
Method Summary
Modifier and TypeMethodDescriptionApplies a topology in the requested mode.Works out what applying a topology would do, without doing any of it.
-
Method Details
-
plan
Works out what applying a topology would do, without doing any of it.- Parameters:
topology- what should exist- Returns:
- the plan
-
apply
Applies a topology in the requested mode.- Parameters:
topology- what should existmode- how much the apply is allowed to do- Returns:
- the plan that was computed, whether or not it was carried out
- Throws:
AceMqException- inApplyMode.VALIDATEwhen something is missing, or when a quorum queue is requested from a broker that cannot provide one
-