• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MDB Topic & Queue

 
saran ram
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Message-Driven beans for both Topic & Queue, Only one bean from that
particular Bean Pool is going to get the message? Is it right? can somebody explain bit more about this?
 
Timothy Toe
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As for this issue, HFEJB did a good job explaining it clearly. Just need to read it carefully.

[Only one bean from that particular Bean Pool is going to get the message?] - Yes... only 1 INSTANCE of A BEAN TYPE is going to get the message.

Let's say you have a server that takes in SMSes to process from a Telco's server. All SMSes will be parked as JMS messages at a Topic in your J2EE server. You have a type of MDB that adds 2 numbers in the SMS (eg. of sms content is "5 7", so your MDB will do 5+7=12). Your MDB needs to do some real work on the message. You name your MDB "AdditionMDB". If your Container instantiated 10 instances of your AdditionMDBs in the pool, and if a single message "4 5" comes, how many instances of AdditionMDBs you need to do the work ? All 10 instances doing 4+5=9 ? Just 1 instance of AdditionMDB will be enough ! Container will only pull 1 AdditionMDB out of the pool to do the work.

Now imagine that you have a SubtractionMDB. And that both AdditionMDB SubtractionMDB are subcribed to that same Topic. Your container gets ready 10 AdditionMDB and 10 SubtractionMDB. Do you think you need to do 10 addition work which are the same ? Do you think you need to do 10 subtraction work which are the same ? The container will be doing this if every instance is pulled out of the pool when a message comes. Talk about wasting time and energy.

Only 1 instance of each type of MDB will be pulled out of the pool to work on a msg. Only 1 instance of AdditionMDB & 1 instance of SubtractionMDB will be asked to work on the message.

Those reading this, if there is anything wrong with my explaination, kindly correct me.
 
saran ram
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Timothy. In Queue just only one Bean type is going to receive a particular message and in Topic several Bean types are going to receive a particular message, but in both cases, just one instance from the bean pool is going to work on the message. Right?
 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly right. Container can create any number of beans in the pool. But only one bean instance can work on a message at any given time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic