Class AmqpMessageSubscriber

java.lang.Object
org.mockserver.async.subscribe.AmqpMessageSubscriber
All Implemented Interfaces:
MessageSubscriber

public class AmqpMessageSubscriber extends Object implements MessageSubscriber
A MessageSubscriber that consumes from an AMQP 0.9.1 broker (RabbitMQ) using the official com.rabbitmq:amqp-client library, the consumer-side counterpart of AmqpMessagePublisher.

Like the publisher, the AMQP source of a channel is derived from the channel's AmqpBinding (channels.<name>.bindings.amqp) — the AsyncAPI channel name does not map directly to a queue the way a Kafka/MQTT topic does:

  • is: queue (or no binding) — consume directly from the queue named by queue.name (or the channel name). The queue is declared (durable per queue.durable) so recording works against a fresh broker, matching the publisher's queue declaration.
  • is: routingKey — declare the binding's exchange.name (idempotently, with the binding's type/durability), declare a private server-named exclusive auto-delete queue, and bind it to the exchange on the routing key (the binding's explicit routingKey, else the channel name). Messages published to that exchange/routing-key are then recorded.

Recorded messages carry the AMQP message-property headers (if any) as the RecordedMessage headers; the key is always null (AMQP has no per-message key concept the way Kafka does). Recorded messages are stored in a bounded BoundedMessageStore per channel to prevent unbounded memory growth.

  • Constructor Details

    • AmqpMessageSubscriber

      public AmqpMessageSubscriber(String amqpUri, AsyncApiSpec spec, int maxRecordedMessages)
      Connect to an AMQP broker from a connection URI and resolve per-channel consume sources from the given spec.
      Parameters:
      amqpUri - the AMQP connection URI (e.g. amqp://user:pass@host:5672/vhost)
      spec - the loaded AsyncAPI spec (used to map channel names to AMQP bindings); may be null
      maxRecordedMessages - maximum recorded messages retained per channel
  • Method Details