*
The moose likes EJB and other Java EE Technologies and the fly likes MDB Pool subscribed to a Topic 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 Pool subscribed to a Topic" Watch "MDB Pool subscribed to a Topic" New topic
Author

MDB Pool subscribed to a Topic

Sameer Boddun
Greenhorn

Joined: Nov 05, 2001
Posts: 3
In MDB deployment descriptor we define <max-beans-in-free-pool> and <initial-beans-in-free-pool> elements.
During their deployment the number of beans given in <initial-beans-in-free-pool> tag are created.
For example:
----------------------------------------
<message-driven-descriptor>
<pool>
<max-beans-in-free-pool>200</max-beans-in-free-pool>
<initial-beans-in-free-pool>20</initial-beans-in-free-pool>
</pool>
<destination-jndi-name>quotes</destination-jndi-name>
</message-driven-descriptor>
Here in example <destination-jndi-name> is jndi name for Topic destination.
----------------------------------------
Once the server is started the 20 bean instances are created. And they are ready to receive messages.
because all 20 instances of the bean have subscribed to the single Topic, all the instances should receive the message. But, this is not happening!, only one instance in the pool is receiving message.
I have tried this on Weblogic 6.1 server, and have no idea whether other Application servers allow to create such pools.
Any way, my question is,
1) All the 20 instances have same implementation of OnMessage method, then why we should create the pool? Is the any other advantages, that i am not able to think of?
2) How the server is managing to pass the message to only one instance in the pool, in-spite of the fact that the bean implements MessageListener interface?


Sameer Boddun
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The pool is used for serving multiple concurrent messages. For example, if your topic receives two messages, the EJB Container picks two instances from the pool of that particular MDB to process the two messages.
If you want 20 MDBs to process every message for a topic, you need to deploy your MDB 20 times (with different JNDI names of course) each having its own instance pool -- possibly of varying sizes.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Sameer Boddun
Greenhorn

Joined: Nov 05, 2001
Posts: 3
You are right!!, Thanks for helping...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MDB Pool subscribed to a Topic