Class TopologySpec

java.lang.Object
org.acemq.workloads.TopologySpec

public final class TopologySpec extends Object
What the workload publishes to and consumes from.

 .topology(t -> t
         .exchange("orders", "topic")
         .queue("orders.new").quorum()
         .boundTo("orders", "order.created"))
 

One exchange and one queue, deliberately. A workload that fans out across many queues is a different measurement, and combining the two in one spec produces results nobody can attribute — the interesting comparison is several runs, not one run with everything in it.

  • Method Details

    • exchange

      public TopologySpec exchange(String name, String type)
      Parameters:
      name - the exchange to publish to. The default exchange is "", which routes by queue name and skips exchange routing entirely — the fastest path, and not what most systems do
      type - topic, direct, fanout or headers
      Returns:
      this spec
    • queue

      public TopologySpec queue(String name)
      Parameters:
      name - the queue to consume from
      Returns:
      this spec
    • boundTo

      public TopologySpec boundTo(String exchangeName, String key)
      Parameters:
      exchangeName - the exchange to bind to
      key - the binding key, which is also the routing key publishes will use
      Returns:
      this spec
    • routingKey

      public TopologySpec routingKey(String key)
      Parameters:
      key - the routing key publishes use, when it differs from the binding key
      Returns:
      this spec
    • quorum

      public TopologySpec quorum()
      A quorum queue: replicated, durable, and slower than classic by design.

      Worth measuring rather than assuming. The throughput difference against a classic queue is large, and it is the price of the guarantee — a comparison run is the honest way to decide whether the guarantee is affordable at your rate.

      Returns:
      this spec
    • classic

      public TopologySpec classic()
      Returns:
      this spec, with a classic queue (the default)
    • argument

      public TopologySpec argument(String name, Object value)
      Parameters:
      name - a queue argument
      value - its value
      Returns:
      this spec
    • useExisting

      public TopologySpec useExisting()
      Uses the topology as it already exists rather than declaring it.

      The right choice when measuring a real environment: declaring would either be refused for mismatched arguments or, worse, would create something subtly different from what production runs and measure that instead.

      Returns:
      this spec
    • exchange

      public String exchange()
    • exchangeType

      public String exchangeType()
    • queue

      public String queue()
    • routingKey

      public String routingKey()
      The key publishes go out with.

      On the default exchange the routing key is the queue name — that is the whole of how the default exchange routes — so naming a queue and not naming a key has exactly one sensible reading, and it is the queue. Returning the unrelated default instead published every message to a queue of that name, which in general does not exist, and the broker drops an unroutable message on the default exchange without saying anything. Publishers publishing, confirms arriving, queue empty, consumers idle: a run that looks alive and changes nothing. A drill cluster ran that way for a while before anybody noticed.

      Only when the key was never set. Someone who writes both a queue and a routing key means both, even on the default exchange where that combination cannot route — and the scenario's own validation refuses that by name rather than it being quietly corrected here.

      Returns:
      the routing key, which on the default exchange defaults to the queue name
    • queueType

      public String queueType()
    • queueArguments

      public Map<String,Object> queueArguments()
    • shouldDeclare

      public boolean shouldDeclare()
    • usesDefaultExchange

      public boolean usesDefaultExchange()
      Returns:
      whether publishes go through the default exchange
    • toString

      public String toString()
      Overrides:
      toString in class Object