Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

MDB state

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If MDB is stateless, how can the messages forward to multiple clients?
To check the content of the message before forwarding?

Thanks
 
author
Posts: 4173
29
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Scott Selikoff
author
Posts: 4173
29
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"whatIsThis Idontknow "

I almost forgot, please update your name to conform to the Java Ranch naming policy.
 
Allen Springers
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Posts: 4173
29
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
Seriously? That's what you're going with? I prefer this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic