How it works...

Thanks to the standards implemented in the Java EE 8 server, our MDB is 100% managed by the container. That's why we could just refer to the queue without looking back:

@MessageDriven(activationConfig = {    @ActivationConfigProperty(propertyName = "destinationLookup",     propertyValue = "jms/JmsQueue"),    @ActivationConfigProperty(propertyName = "destinationType",     propertyValue = "javax.jms.Queue")})

We could have built a Consumer by our own hands, but it would build three times as many code lines and would be synchronous.

We get our container Producer from a session provided by our factory and made for our queue:

        try (Connection connection = jmsFactory.createConnection();              Session session = connection.createSession(false,  Session.AUTO_ACKNOWLEDGE)) ...

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.