Spring AMQP (RabbitMQ)
Spring integration for RabbitMQ — provides RabbitTemplate for sending messages, @RabbitListener for consuming, and declarative exchange/queue/binding configuration via Beans. Spring AMQP features: RabbitTemplate.convertAndSend() for publishing, @RabbitListener(queues='agent.tasks') for consuming, automatic message conversion (JSON via Jackson2JsonMessageConverter), dead letter queues via x-dead-letter-exchange config, retry with fixed/exponential backoff (RetryInterceptorBuilder), SimpleRabbitListenerContainerFactory for concurrency control, RabbitAdmin for declarative queue/exchange declaration, and @RabbitListenerContainerFactory for per-listener configuration. Spring Boot auto-configuration via spring-boot-starter-amqp.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
RABBITMQ_PASSWORD must be externalized via environment variables or Vault — never hardcode in application.yml for agent services. Enable TLS (spring.rabbitmq.ssl.enabled=true) for production agent message encryption in transit. Virtual hosts provide agent tenant isolation but require per-vhost permission configuration.
⚡ Reliability
Best When
Your agent service needs reliable async task distribution, event fanout to multiple consumers, and complex routing logic — RabbitMQ's exchange/binding model excels at message routing patterns.
Avoid When
You need event replay, high-throughput streaming, or log-based message retention — use Kafka. If workload is simple task queue, consider Redis with Spring Data Redis instead.
Use Cases
- • Agent task queue — @RabbitListener(queues = 'agent.tasks') public void processTask(AgentTask task) {} consumes agent tasks from RabbitMQ; RabbitTemplate.convertAndSend('agent.tasks', task) publishes from agent API; automatic JSON serialization via Jackson2JsonMessageConverter
- • Agent event fanout — TopicExchange + bindings route agent.event.* messages to multiple queues; agent notifications, audit logging, and analytics services each receive copies via exchange routing without direct coupling
- • Dead letter queue for failed agent tasks — queue declared with x-dead-letter-exchange=agent.dlx retries failed agent processing; RabbitMQ moves messages to DLQ after maxAttempts; agent ops team inspects/requeues failed tasks from DLQ
- • Priority agent tasks — @RabbitListener with concurrency = '3-10' scales agent task consumers from 3 to 10 threads based on queue depth; high-priority agent tasks in separate queue with dedicated consumer group get SLA guarantee
- • Agent saga orchestration — RabbitTemplate.convertAndSend() publishes compensation events when agent step fails; downstream services consume compensation topic and roll back; AMQP topics enable agent workflow coordination without tight coupling
Not For
- • High-throughput streaming — RabbitMQ/AMQP per-message acknowledgment overhead limits throughput vs Kafka; for agent event streaming at millions/sec use Spring Kafka
- • Event sourcing and replay — RabbitMQ queues are transient; consumed messages are gone; for agent event replay and audit log use Kafka with log retention
- • Request-reply RPC — Spring AMQP supports RPC pattern but HTTP is more natural for synchronous agent calls; use Spring AMQP for fire-and-forget async agent messaging
Interface
Authentication
RabbitMQ authenticates via username/password configured in spring.rabbitmq.username/password. TLS client certificates supported. Virtual hosts provide tenant isolation for agent queues.
Pricing
Spring AMQP is Apache 2.0. RabbitMQ is MPL licensed open source. Managed hosting services have their own pricing.
Agent Metadata
Known Gotchas
- ⚠ Default message converter sends Java-serialized bytes — without Jackson2JsonMessageConverter, RabbitTemplate sends Java serialization; polyglot agent consumers (Python, Node.js) can't deserialize; always configure Jackson2JsonMessageConverter as default message converter bean for JSON interoperability
- ⚠ prefetchCount defaults to 250 — high prefetch causes one slow agent consumer to hoard messages from queue; other agent consumer instances starve; set spring.rabbitmq.listener.simple.prefetch=1 for fair dispatch of expensive agent tasks; tune up only for lightweight agent messages
- ⚠ @RabbitListener method exceptions requeueing loop — uncaught exceptions in @RabbitListener requeue message by default causing infinite retry loop; configure error handler or throw AmqpRejectAndDontRequeueException to send to DLQ; agent task processing failures must explicitly reject-without-requeue or configure retry interceptor with max attempts
- ⚠ Queue declaration requires matching arguments — if agent queue was declared with x-dead-letter-exchange and RabbitAdmin redeclares with different arguments, PRECONDITION_FAILED error causes connection failures; changing queue arguments requires deleting and recreating queue in RabbitMQ; agent deployments changing DLQ config must handle queue recreation
- ⚠ Jackson type information required for polymorphic messages — Jackson2JsonMessageConverter without TypeMapper sends raw JSON; deserializing to AgentTask interface fails with 'No type information' exception; use DefaultJackson2JavaTypeMapper with idClassMapping or include @class header in messages for agent polymorphic event hierarchies
- ⚠ Concurrency and maxConcurrency require queue consumer scaling — spring.rabbitmq.listener.simple.concurrency=3 starts 3 consumer threads; maxConcurrency=10 allows scaling to 10; RabbitMQ must have consumers present for messages to flow; agent services starting with concurrency=1 may be bottleneck until auto-scaling adds consumers
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for Spring AMQP (RabbitMQ).
Scores are editorial opinions as of 2026-03-06.