I am not sure it is entirely reasonable to expect anyone to explain this in a forum post. Most decent EJB 3.0 references (some of which are free) should answer these questions for you. In short, MDBs are used to process messages (usually JMS messages) in a declarative fashion with minimal infrastructure code in a robust manner. MDBs are typically used in environments where a messaging server like IBM MQ-Series are in use.
Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
Simple answer to your question is - to implement asynchronous use case.
When ever client of a service don't want to wait for completing of the call is the example of asynchronous case. Queue is used in most of the solutions. Only resposibilty of client is to put one message in the queue. Client can go ahead without worring about how, when, who will process the message.
MDB is always the consumer of that queue. MDB never be called like session or entity bean directly by client. MDB is called by container whenever there is message in the destination queue for the consumpation.
I will give you one simple example. Invetory managment system may have MDB litening to low invetory queue. Order Managmenet system may write to the queue in case inventory for perticular product falling below some level.
i just wanted know that where MDBs are used in real life ??
I know that it has to do with deciding synchronous & asynchronous communication ...........
but i could not really understand its real use and advantage in real life.
so can any one please answer following doubts regarding MDB?
1) Why to use MDB?
2) Where to use MDB?
3) what are advantages of using MDB?
4) where exactly MDBs are used in real life?
5) can any one give any simple small demo of proper use of MDB with code?
I will really appreciate if any one can give any simple MDB application demo with code .
1) Why to use MDB? : It is scalable and powerful lightweight mechanism to message communication.
2) Where to use MDB? : when you want to communicate with two heterogeneous system.
3) what are advantages of using MDB? : asynchronous message communication with multithreaded/paralleism(Best of CPU utilisation)
4) where exactly MDBs are used in real life? : where required Old Native system with new system integration.
5) can any one give any simple small demo of proper use of MDB with code? : Check the net you will get lots of stuffs.