Skip to main content
RabbitMQ integration enables you to stream WhatsApp events to RabbitMQ queues for asynchronous processing, load balancing, and microservices architecture.

Configuration

Configure RabbitMQ connection and event routing through environment variables.

Connection Settings

.env
The connection URI format is: amqp://username:password@host:port/vhost
  • Default port: 5672
  • Default vhost: /
  • For RabbitMQ with SSL, use amqps:// protocol

Global vs Instance Events

You can configure RabbitMQ to work in two modes:
Each instance gets its own queues and exchange:
.env
Creates queues like:
  • my_instance.messages.upsert
  • my_instance.qrcode.updated
  • my_instance.connection.update

Exchange and Queue Setup

Evolution API automatically creates:
1

Topic Exchange

A topic exchange with the configured name (default: evolution)
  • Durable: Survives broker restarts
  • Type: Topic (enables routing pattern matching)
2

Quorum Queues

Queues for each enabled event:
  • Durable: Messages persist to disk
  • Type: Quorum (replicated, highly available)
  • Auto-delete: Disabled
3

Queue Bindings

Bindings between queues and exchange using routing keys:
  • Routing key format: event name (e.g., MESSAGES_UPSERT)
  • Enables selective event consumption

Available Events

Configure which events are sent to RabbitMQ:
.env

Per-Instance Configuration

Configure RabbitMQ events for a specific instance via API:

Message Format

Messages published to RabbitMQ have the following JSON structure:

Consuming Events

Here are examples of consuming events from RabbitMQ:

Connection Resilience

Evolution API implements automatic reconnection with exponential backoff:
  • Initial delay: 5 seconds
  • Maximum attempts: 10
  • Exponential backoff: Delay doubles each attempt (up to 5 times)
  • Heartbeat: 30 seconds to detect connection loss
During connection loss, Evolution API will queue events in memory and retry delivery. Monitor your RabbitMQ connection status in the logs.

Best Practices

1

Use Quorum Queues

Evolution API creates quorum queues by default for high availability and data safety. Ensure your RabbitMQ cluster has at least 3 nodes for optimal quorum queue performance.
2

Enable Acknowledgments

Always acknowledge messages after successful processing to prevent message loss:
3

Handle Processing Errors

Implement error handling and use dead letter queues for failed messages:
4

Set Prefetch Count

Limit concurrent message processing per consumer:
5

Monitor Queue Depth

Set up alerts for queue depth to detect processing bottlenecks.
Quorum queues require RabbitMQ 3.8.0 or later. If you’re using an older version, Evolution API will fall back to classic durable queues.

Troubleshooting

  1. Verify RabbitMQ is running: systemctl status rabbitmq-server
  2. Check the connection URI in your .env file
  3. Ensure firewall allows port 5672 (or your configured port)
  4. Verify credentials are correct
  1. Check that specific events are enabled in configuration
  2. Verify RABBITMQ_ENABLED=true
  3. Check Evolution API logs for RabbitMQ errors
  4. Ensure the instance is connected to WhatsApp
  1. Verify queue binding to exchange
  2. Check routing key matches event name
  3. Ensure consumer is acknowledging messages
  4. Check for messages in dead letter queue
  1. Check queue depth - consumers may be too slow
  2. Increase number of consumers
  3. Optimize message processing code
  4. Consider increasing RABBITMQ_FRAME_MAX if messages are large