Java EJB Programming Question:

Download Job Interview Questions and Answers PDF

What is the difference between Message Driven Beans and Stateless Session beans?

Java EJB Programming Interview Question
Java EJB Programming Interview Question

Answer:

In several ways, the dynamic creation and allocation of message-driven bean instances mimics the behavior of stateless session EJB instances, which exist only for the duration of a particular method call. However, message-driven beans are different from stateless session EJBs (and other types of EJBs) in several significant ways: Message-driven beans process multiple JMS messages asynchronously, rather than processing a serialized sequence of method calls. Message-driven beans have no home or remote interface, and therefore cannot be directly accessed by internal or external clients. Clients interact with message-driven beans only indirectly, by sending a message to a JMS Queue or Topic.

Only the container directly interacts with a message-driven bean by creating bean instances and passing JMS messages to those instances as necessary. The Container maintains the entire lifecycle of a message-driven bean; instances cannot be created or removed as a result of client requests or other API calls.

Download Java EJB Programming Interview Questions And Answers PDF

Previous QuestionNext Question
What happens if remove( ) is never invoked on a session bean? How can I call one EJB from inside of another EJB?