Skip to content

Proposal: New Java RabbitMQ Skill with Enterprise Integration Patterns (EIP) #130

@giuseppe-trisciuoglio

Description

@giuseppe-trisciuoglio

Proposal: New Java RabbitMQ Skill with Enterprise Integration Patterns (EIP)

Description

This proposal introduces a new skill for the developer-kit focused on Java and RabbitMQ, specifically designed to handle complex asynchronous operations using Enterprise Integration Patterns (EIP). The skill will provide standardized workflows and code templates for common messaging scenarios, ensuring reliability, scalability, and maintainability.

Key Features & Patterns

The skill will cover the following core EIP and RabbitMQ-specific configurations:

1. FIFO Queue (Single Active Consumer)

Ensures strict message ordering by allowing only one consumer to be active at a time, even if multiple instances are connected.

  • Pattern: Single Active Consumer
  • Implementation: Configuration of x-single-active-consumer: true on the queue.
  • Use Case: Sequential processing of orders or state-dependent events.

2. Competing Consumers

Scales message processing by allowing multiple consumers to pull from the same queue.

  • Pattern: Competing Consumers
  • Implementation: Default RabbitMQ behavior with optimized prefetch counts to ensure fair distribution.
  • Use Case: High-throughput background tasks like image processing or email delivery.

3. Dead Letter Exchange (DLQ)

Handles message failures gracefully by routing unprocessable messages to a dedicated exchange/queue for inspection or retry.

  • Pattern: Message Redelivery / Dead Letter Channel
  • Implementation: Setting x-dead-letter-exchange and x-dead-letter-routing-key arguments.
  • Use Case: Error handling in production environments.

4. Idempotent Receiver

Prevents side effects from duplicate message delivery.

  • Pattern: Idempotent Receiver
  • Implementation: Java templates using unique message IDs and database checks.

Proposed Structure

plugins/developer-kit-java/skills/rabbitmq-eip/
├── SKILL.md (Core instructions and EIP principles)
├── templates/
│   ├── ProducerTemplate.java (Fluent API for publishing)
│   ├── FifoConsumer.java (Single Active Consumer setup)
│   ├── CompetingConsumer.java (Prefetch and scaling config)
│   └── ErrorHandler.java (DLQ and Retry logic)
└── references/
    ├── rabbitmq-configuration.md (Queue arguments, Exchange types)
    ├── eip-mapping.md (Mapping RabbitMQ features to EIP)
    └── error-handling-strategies.md (Retry vs. DLQ vs. Parking Lot)

Why this is needed

Managing RabbitMQ in Java often leads to boilerplate code and inconsistent error handling. By providing a skill that enforces EIP, we:

  • Reduce "reinventing the wheel" for common messaging patterns.
  • Improve system resilience through standardized DLQ and Retry patterns.
  • Ensure developers choose the right pattern (FIFO vs. Competing) based on business requirements.

Example Usage (Preview)

// Template for a Reliable Producer with EIP
@Component
public class OrderProducer {
    private final RabbitTemplate rabbitTemplate;

    public void sendOrder(Order order) {
        rabbitTemplate.convertAndSend("order-exchange", "order.created", order, message -> {
            message.getMessageProperties().setCorrelationId(order.getId());
            return message;
        });
    }
}

Requested by: @giuseppe-trisciuoglio

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions