Building reactive applications using message-driven beans
The Java Messaging Service is one of the oldest Java EE APIs, and it's been reactive since day one: just read the manifesto linked in the introduction of this chapter.
This recipe will show you how to use message-driven beans, or MDBs, to deliver and consume asynchronous messages with just a few annotations.
Getting ready
Let's first add our Java EE 8 dependency:
<dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>8.0</version> <scope>provided</scope> </dependency>
To check the details about queue setup in GlassFish 5, please refer to the recipe Using Messaging Services for Asynchronous Communication at Chapter 5, Security of Enterprise Architecture.
How to do it...
- First, we create a
User
POJO:
public class User implements Serializable{ private Long id; private String name; public User(long id,...