Enterprise advanced

Message-Driven Bean vs Reactive Messaging

Replace JMS Message-Driven Beans with MicroProfile Reactive Messaging for simpler event processing.

✕ Java EE
@MessageDriven(activationConfig = {
    @ActivationConfigProperty(
        propertyName = "destinationType",
        propertyValue = "jakarta.jms.Queue"),
    @ActivationConfigProperty(
        propertyName = "destination",
        propertyValue = "java:/jms/OrderQueue")
})
public class OrderMDB implements MessageListener {
    @Override
    public void onMessage(Message message) {
        TextMessage txt = (TextMessage) message;
        processOrder(txt.getText());
    }
}
✓ MicroProfile 4+
@ApplicationScoped
public class OrderProcessor {
    @Incoming("orders")
    public void process(Order order) {
        // automatically deserialized from
        // the "orders" channel
        fulfillOrder(order);
    }
}
🪶

Minimal code

A single @Incoming method replaces the MDB class, MessageListener interface, and activation config.

🔌

Broker-agnostic

Swap Kafka, AMQP, or JMS connectors via configuration without changing application code.

☁️

Cloud-native fit

Reactive streams backpressure and lightweight runtime make it ideal for containerised deployments.

Old Approach
Message-Driven Bean
Modern Approach
Reactive Messaging
Since JDK
11
Difficulty
advanced
Message-Driven Bean vs Reactive Messaging
Available

Available since MicroProfile 4.0 / SmallRye Reactive Messaging

Message-Driven Beans require implementing MessageListener, configuring activation properties, and manually deserializing JMS messages. MicroProfile Reactive Messaging uses a simple @Incoming annotation on a method that receives typed objects directly. The channel configuration is externalised, making the code broker-agnostic and far easier to test.

Share 𝕏 🦋 in