Class BrokerCapabilities

java.lang.Object
org.acemq.workloads.scenario.BrokerCapabilities

public final class BrokerCapabilities extends Object
What a particular broker will actually give you.

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 Details

    • of

      public static BrokerCapabilities of(String managementUrl, String username, String password)
      Asks the broker what it is.
      Parameters:
      managementUrl - the management API, for example http://localhost:15672
      username - a user that may read the overview
      password - its password
      Returns:
      what that broker supports, or unknown() if it could not be asked
    • forVersion

      public static BrokerCapabilities forVersion(String version)
      Parameters:
      version - a broker version such as 4.0.5
      Returns:
      what a broker of that version supports
    • unknown

      public static BrokerCapabilities unknown()
      Returns:
      what to assume when the broker cannot be asked: classic and quorum, and honest about being a guess
    • version

      public String 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

      public Set<QueueType> queueTypes()
      Returns:
      the queue types this broker will honour
    • supports

      public boolean supports(QueueType type)
      Parameters:
      type - a queue type
      Returns:
      whether this broker will honour it
    • whyNot

      public String whyNot(QueueType type)
      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

      public String toString()
      Overrides:
      toString in class Object