File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes MDB state 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 state" Watch "MDB state" New topic
Author

MDB state

Allen Springers
Greenhorn

Joined: Oct 23, 2007
Posts: 4
If MDB is stateless, how can the messages forward to multiple clients?
To check the content of the message before forwarding?

Thanks
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

I don't understand the question. Why do you think MDB's need to be stateful to forward to multiple clients?

As a side note, there are ways to make MDBs function as having state, but again, I don't understand what this has to do with sending messages.


My Blog: Down Home Country Coding with Scott Selikoff
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

"whatIsThis Idontknow "

I almost forgot, please update your name to conform to the Java Ranch naming policy.
Allen Springers
Greenhorn

Joined: Oct 23, 2007
Posts: 4
I was reading an article on Sun's website
It says that A message-driven bean has no state for a specific client, but its instance variables can contain state across the handling of client message, including an open database connection and an object reference to an EJB object

From my understanding, the client application must also locate in the server where MDB is located.
Then, inside the client application, I create a MDB object and call its onMessage() method to check messages and determine the owner of the message?

Please let me know if my understanding is not correct

Thanks
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

Originally posted by Allen Springers:
From my understanding, the client application must also locate in the server where MDB is located.


No, the client must know where the queue for the MDB is. It doesn't have to know anything about the MDB.

Originally posted by Allen Springers:
Then, inside the client application, I create a MDB object and call its onMessage() method to check messages and determine the owner of the message?


It sounds like your mixing MDB code with EJB code, but I could be wrong. In general, the message should contain information about who sent it or in the case that it doesn't, you can encode that information in the header (not the content) of the message before sending to the MDB.

I still don't understand what any of this has to do with state. Every time an MDB gets a message off the queue, it can just decode the header (or if needs to the content) to determine where the message came from. Generally you only want an MDB decoding the content if its going to do something with it. A lot of times, though, MDBs are placed as routing mechanisms in which they read the header and then pass to a session bean.
[ October 24, 2007: Message edited by: Scott Selikoff ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MDB state
 
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