Durable Message Driven Beans in WildFly
With Message Driven Beans (MDB’s) your Java application can respond to events send asynchronously. This can go via Queues, which allow your application to process events in parallel, and Topics which can be used to send one event to multiple applications/clients. MDB’s can be annotated to configure which JMS-Topic they should listen to. This is how that can be done:
1 2 3 4 5 6 7 8 9 10 |
@MessageDriven(name = "ExampleEventListener", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "/jms/topic/exampleEvents"), @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") }) public class ExampleEventListener implements MessageListener { @Override public void onMessage(Message message) { // TODO: do something } } |