Class BrokerCapabilities
Queue types are not a fixed list. Streams arrived in 3.9 and need a feature flag; mirrored classic queues were removed in 4.0, and a 4.x broker accepts the policy that used to create them and then ignores it. Offering all four in a designer and letting the broker sort it out produces the worst outcome available: a run that succeeds, reports confidently, and measured a plain classic queue while the label said something else.
So the studio asks first:
BrokerCapabilities capabilities = BrokerCapabilities.of(
"http://localhost:15672", "guest", "guest");
if (capabilities.supports(QueueType.STREAM)) {
// offer it
}
When the management API is not reachable — it is a separate port and often closed — the
answer is unknown(), which claims the two types every broker in living memory has and
says it is guessing. A guess that is announced is usable; a guess that is not is a bug report
six months later.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BrokerCapabilitiesforVersion(String version) booleanisKnown()static BrokerCapabilitiesAsks the broker what it is.booleantoString()static BrokerCapabilitiesunknown()version()Why a type is not on offer, in a sentence somebody can act on.
-
Method Details
-
of
Asks the broker what it is.- Parameters:
managementUrl- the management API, for examplehttp://localhost:15672username- a user that may read the overviewpassword- its password- Returns:
- what that broker supports, or
unknown()if it could not be asked
-
forVersion
- Parameters:
version- a broker version such as4.0.5- Returns:
- what a broker of that version supports
-
unknown
- Returns:
- what to assume when the broker cannot be asked: classic and quorum, and honest about being a guess
-
version
- Returns:
- the broker's version, or null when it could not be asked
-
isKnown
public boolean isKnown()- Returns:
- whether these capabilities came from a broker rather than from an assumption
-
queueTypes
- Returns:
- the queue types this broker will honour
-
supports
- Parameters:
type- a queue type- Returns:
- whether this broker will honour it
-
whyNot
Why a type is not on offer, in a sentence somebody can act on.- Parameters:
type- the type they wanted- Returns:
- the reason, or null when it is supported
-
toString
-