News KrakenD CE v2.6 released with OpenTelemetry

Enterprise Documentation

Recent changes

You are viewing a previous version of KrakenD Enterprise Edition (v2.1) , go to the latest version

Gateway integration with RabbitMQ consumers

Document updated on Jan 24, 2022

The AMQP component allows to send and receive messages to and from a queue through the API Gateway.

The configuration of the queue is a straightforward process. To connect the endpoints to the messaging system you only need to include the extra_config key with the namespaces backend/amqp/consumer or backend/amqp/producer.

To create Async agents that consume messages asynchronously and without requiring a user request, see Async Agents.

The parameters of this integration follow the AMQP specification. To understand what are the implications of a certain parameter, see the AMQP Complete Reference Guide.

KrakenD creates both the exchange and the queue for you.

Configuration

The consumer retrieves messages from the queue when a KrakenD endpoint plugs to its AMQP backend. The recommendation is to connect consumers to GET endpoints.

A single endpoint can consume messages from N queues, or can consume N messages from the same queue by adding N backends with the proper queue name.

See Async Agents to consume messages without an endpoint.

The needed configuration to run a consumer is:

{
    "backend": [{
        "host": ["amqp://guest:[email protected]:5672"],
        "disable_host_sanitize": true,
        "extra_config": {
            "backend/amqp/consumer": {
                "name": "queue-1",
                "exchange": "some-exchange",
                "durable": true,
                "delete": false,
                "no_wait": true,
                "no_local": false,
                "routing_key": ["#"],
                "prefetch_count": 10,
                "prefetch_size": 1024,
                "auto_ack": false
            }
        }
    }]
}
Fields of AMQP Consumer "backend/amqp/consumer"
* required fields
auto_ack

boolean
When KrakenD retrieves the messages, regardless of the success or failure of the operation, it marks them as ACKnowledge.
Defaults to false
delete  *

boolean
Setting to false is recommended to avoid deletions when the consumer is disconnected.
Defaults to false
durable  *

boolean
Durable queues will survive server restarts and remain when there are no remaining consumers or bindings. true is recommended, but depends on the use case.
Defaults to false
exchange  *

string
The exchange name (must have a topic type if already exists).
Example: "some-exchange"
name  *

string
Queue name.
no_local

boolean
The no_local flag is not supported by RabbitMQ.
no_wait  *

boolean
When true, do not wait for the server to confirm the request and immediately begin deliveries. If it is not possible to consume, a channel exception will be raised and the channel will be closed.
prefetch_count

integer
The number of messages you want to prefetch prior to consume them.
Defaults to 10
prefetch_size

integer
The number of bytes you want to use to prefetch messages.
Defaults to 1024
routing_key  *

array
The list of routing keys you will use to consume messages.
Example: "#"
Scarf

Unresolved issues?

The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.

We use cookies to understand how you use our site and to improve your overall experience. By continuing to use our site, you accept our Privacy Policy. More information