10.3. JMS and EJBs

An EJB application can interact with a messaging service in either or both of the following two ways.

  • EJBs can send messages to queues or publish to topics in exactly the same way as standalone JMS clients. Ideally, the EJB will be able to locate queues and connection factories by making JNDI lookup() calls on the container’s default InitialContext(). However, at present not all containers support JMS directly, and the EJB may need to specify the initial naming factory and URL explicitly (as described on page 204).

  • Message-driven EJBs can receive messages from queues or topics (since EJB2.0). This is the only way that EJBs can receive messages: They can’t create MessageConsumer objects directly. [4] Why is this? The problem ...

Get Applied Enterprise JavaBeans™ Technology 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.