jakarta-eeejbmessage-driven-beansession-bean

Why not use Session Beans instead of Message Driven Beans?


I'm wondering, why not use Session Beans instead of Message Driven Beans ?

If you can call remote methods from EJBs, so why bother sending/receiving messages with Message Driven Beans (which is more difficult to develop than session beans) ?

In which scenarios Message Driven Beans become useful ?


Solution

  • I'm wondering, why not use Session Beans instead of Message Driven Beans ?

    Hmm, they don't serve the same purpose, message-driven beans allow Java EE applications to process messages asynchronously.

    If you can call remote methods from EJBs, so why bother sending/receiving messages with Message Driven Beans (which is more difficult to develop than session beans) ?

    Because MDBs give you asynchronism and loose coupling, which is something you might want/need in some situations:

    By the way, I've personally always found MDBs to be the easiest Enterprise Beans to develop.

    In which scenarios Message Driven Beans become useful ?

    See above.

    See also