Class QueueNode

java.lang.Object
org.acemq.workloads.scenario.QueueNode
All Implemented Interfaces:
Node

public final class QueueNode extends Object implements Node
A queue in a scenario, its bindings, and the consumers on it.

The consumers belong to the queue rather than to the scenario because that is where the interesting asymmetry lives: a fan-out with eight consumers on one queue and one on another is the shape that produces a backlog on exactly one leg, and a model with a single consumer block cannot describe it.

  • Method Details

    • classic

      public QueueNode classic()
      Returns:
      this queue, as a classic queue
    • quorum

      public QueueNode quorum()
      Returns:
      this queue, as a quorum queue: replicated, durable, and slower by design
    • stream

      public QueueNode stream()
      Returns:
      this queue, as a stream: an append-only log that consumers read at their own offset
    • mirrored

      public QueueNode mirrored()
      A classic queue mirrored by an HA policy.

      Only meaningful on RabbitMQ 3.13 and earlier. Mirrored classic queues were removed in 4.0 and quorum queues replaced them, so a scenario using this against a current broker gets a classic queue and a policy nothing honours — which is why the studio hides the option unless the broker it is pointed at is old enough to have it.

      Returns:
      this queue
    • type

      public QueueNode type(QueueType type)
      Parameters:
      type - what kind of queue
      Returns:
      this queue
    • boundTo

      public QueueNode boundTo(String exchange, String routingKey)
      Parameters:
      exchange - where the messages come from
      routingKey - the pattern they arrive under
      Returns:
      this queue
    • deadLetterTo

      public QueueNode deadLetterTo(String exchange)
      Parameters:
      exchange - where rejected and expired messages go
      Returns:
      this queue
    • transient_

      public QueueNode transient_()
      Returns:
      this queue, not surviving a broker restart
    • argument

      public QueueNode argument(String name, Object value)
      Parameters:
      name - a queue argument, such as x-max-length
      value - its value
      Returns:
      this queue
    • broker

      public QueueNode broker(String url)
      The broker this queue actually lives on, when that is not the one the scenario runs against.

      This is how a federation or shovel link gets measured. The link itself is broker configuration and this library does not declare it -- what it can do is stand on both ends of one: a producer publishes to the upstream broker, the link carries the messages, and a consumer group attached here reads them off the downstream queue. End-to-end latency for such a queue is therefore publish-to-arrival across the link, which is the number people actually want from federation and cannot get from either broker alone.

      The measurement is sound because both ends run in this one process: the timestamp travels in the payload as a System.nanoTime() reading, and nanoTime is only comparable within a JVM. Two copies of this tool on two machines would produce a difference between two unrelated clocks rather than a latency.

      A queue on another broker is never declared and its bindings are never created: the link owns that end, and declaring into it would either duplicate what the link already made or fail against an exchange that exists only upstream.

      Parameters:
      url - the broker this queue is on, as an AMQP URL
      Returns:
      this queue
    • enabled

      public QueueNode enabled(boolean enabled)
      Parameters:
      enabled - whether it takes part in the run
      Returns:
      this queue
    • consumers

      public QueueNode consumers(Consumer<ConsumerGroupNode> spec)
      Parameters:
      spec - how many consumers, what prefetch, how slow the handler
      Returns:
      this queue
    • name

      public String name()
      Specified by:
      name in interface Node
      Returns:
      what this node is called
    • type

      public QueueType type()
    • isDurable

      public boolean isDurable()
    • deadLetterExchange

      public String deadLetterExchange()
    • bindings

      public List<Binding> bindings()
    • broker

      public String broker()
      Returns:
      the broker this queue is on, or null for the one the scenario runs against
    • isRemote

      public boolean isRemote()
      Returns:
      whether this queue is on the far side of a link rather than on the run's broker
    • consumersNode

      public ConsumerGroupNode consumersNode()
      Returns:
      the consumers attached to this queue, whether or not they are switched on
    • expect

      public QueueNode expect(Consumer<Expect> objectives)
      What this queue is asked to prove.
      
       .queue("orders.shipping", q -> q.quorum()
               .boundTo("orders", "order.*")
               .expect(e -> e.p99Below(Duration.ofMillis(50)).noBacklog(true)))
       
      Parameters:
      objectives - what to require of it
      Returns:
      this queue
    • expectations

      public Expect expectations()
      Returns:
      what this queue is asked to prove, empty when nothing was asked
    • declaredArguments

      public Map<String,Object> declaredArguments()
      The arguments this queue is declared with, the type and dead-letter settings included.
      Returns:
      the arguments a declaration would carry
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface Node
      Returns:
      whether it takes part in the run
    • toString

      public String toString()
      Overrides:
      toString in class Object