Skip to content

AMQP Connector

The AMQP connector enables publish/subscribe messaging through RabbitMQ and any AMQP 0.9.1 broker, with exchanges, queues, and routing keys.

Connector Types:

  • AmqpReader - Consume messages from a queue or exchange binding
  • AmqpWriter - Publish messages to an exchange with a routing key

Consume messages from an existing queue:

{
"type": "AmqpReader",
"config": {
"url": "amqp://guest:guest@localhost:5672/",
"queue": "sensor_events",
"autoAck": false,
"prefetchCount": 10,
"consumerTag": "meddle-reader"
}
}

When queue is empty and exchange is set, the reader declares a temporary exclusive queue and binds it to the exchange using routingKey:

{
"type": "AmqpReader",
"config": {
"url": "amqp://user:password@rabbit.example.com:5672/",
"exchange": "factory.events",
"routingKey": "line1.*.temperature",
"autoAck": true
}
}
{
"type": "AmqpReader",
"config": {
"url": "amqps://user:password@rabbit.example.com:5671/",
"queue": "secure_events",
"tls": true,
"autoAck": false
}
}

Publish messages to an exchange:

{
"type": "AmqpWriter",
"config": {
"url": "amqp://guest:guest@localhost:5672/",
"exchange": "factory.events",
"routingKey": "line1.temperature",
"mandatory": false,
"contentType": "application/json"
}
}

Publish to Default Exchange (Queue Directly)

Section titled “Publish to Default Exchange (Queue Directly)”

Leave exchange empty and use the queue name as the routing key:

{
"type": "AmqpWriter",
"config": {
"url": "amqp://guest:guest@localhost:5672/",
"exchange": "",
"routingKey": "sensor_events"
}
}
  • url: AMQP connection URI (amqp://user:pass@host:port/vhost or amqps://...)
  • exchange: Exchange name (empty string targets the default exchange)
  • queue: Queue name to consume from (Reader only)
  • routingKey: Routing key or binding pattern
  • tls: Use TLS for the connection
  • prefetchCount: (Reader) Max unacknowledged messages on the channel
  • autoAck: (Reader) Auto-acknowledge messages on delivery
  • consumerTag: (Reader) Client-supplied consumer identifier
  • mandatory: (Writer) Return message to publisher if it cannot be routed
  • contentType: (Writer) MIME type for published messages (default: application/json)
  • autoAck: true - The broker considers messages delivered as soon as they are sent. Faster but messages can be lost on consumer crash.
  • autoAck: false - Meddle explicitly acks each successful message and nacks on payload errors. Use with prefetchCount to bound in-flight messages.

Topic exchanges support wildcards in binding keys:

  • * matches exactly one word: line1.*.temperature
  • # matches zero or more words: factory.#
  • MQTT - Lightweight pub/sub alternative
  • Kafka - High-throughput log-based messaging
  • NATS - Cloud-native pub/sub alternative