@Override public void onMessage(Message msg) { try { User user = msg.getBody(User.class); System.out.println("User: " + user); } catch (JMSException ex) { System.err.println(ex.getMessage()); } }
}
And finally, we create an endpoint, just to send a mock user to the queue:
@Stateless @Path("mdbService") public class MDBService {
@Inject private Sender sender;
public void mdbService(@Suspended AsyncResponse response){ long id = new Date().getTime(); sender.send(new User(id, "User " + id)); response.resume("Message sent to the queue"); } }