my dog learned polymorphism*
The moose likes EJB and other Java EE Technologies and the fly likes MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "MDB" Watch "MDB" New topic
Author

MDB

raj joe
Ranch Hand

Joined: Mar 17, 2005
Posts: 99
What is difference b/w stateless session bean and MDB.
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

MDB or Message Driven Bean are in use when you have to communicate with some JMS servers to achive an Asynchronous communication , or when you want to use some queue to listen on them or when you want to subscribe into some topics in a JMS server.
we use MDB is two way
1- publish/subscribe pattern
usually we use them when we have to announce some events to more than one intrested entity , for example you want to tell 2 or more (dynamicly changes) application that stock price is changed , so they all can update thier status.
in this scenario one who announce the change is a publisher and those application who are intrested in stock change are subscriber. i should tell that subscribers and publishers could be dynamically change.
2-Point-to-Point Messaging
you can use this scenario when you want to delive a message to one and only one listener. in this type you have a queue and some clients on the queue.
in this scenario whichever listener who recive and take the message from queue will own the message and no one else will be allowd to use it.

JMS has some features like :
1-delivery guarantee.
2-persistent message
3-usually failover , Clustring capability
....

A session bean is a logical executer of an application.
you can do your business process in a session bean , for example you can check user authentication in a session bean, you can execute create , find , insert .... over your Entity beans from inside a session bean ...

an stateless session bean could be used for operations that are the same for all users . for example to execute a query , to insert a record ...
when you need to keep track of a user actions and execute an action based on user profiles then you should use an statefull session bean.


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MDB
 
Similar Threads
is it possible to semd messages from MDB to MDB
Issue with jboss tibco integration after tibco EMS restart
system exceptions
[MDB] K&B, What technique is better ?
ejb-jar file 's content