File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes JMS and instance pool of msg driven beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JMS and instance pool of msg driven beans" Watch "JMS and instance pool of msg driven beans" New topic
Author

JMS and instance pool of msg driven beans

Vanessa Hall
Greenhorn

Joined: Dec 11, 2003
Posts: 15
Hi,

I am using JBoss 3.2.5 and trying to use JMS queues. I have set up a queue and a message-driven EJB.

My question has to do with the instance pool for the message-driven beans. When I send a message to the queue, JBoss creates 11 instances of my message-driven bean and onMessage is invoked on all of them.

I thought when using JMS queues, each message has only one consumer?

So my question is in 2 parts:

1. How do I configure the queue so that each message has one consumer? i.e. onMessage is invoked on only one bean.

2. Can I control the size of the instance pool for the message driven beans? I would like to limit the number of beans that can exist at any one time. If more messages come in than there are beans, I would like for it to wait until an existing bean is free instead of creating a new one. I noticed there is a MaxPoolSize attribute in the jmx console, but setting it for the message-driven bean does not seem to have any effect.

My XML:
In ejb-jar.xml:

<message-driven>
<description>Message Driven Bean</description>
<display-name>ScheduleServiceQueueHandler</display-name>
<ejb-name>ScheduleServiceQueueHandler</ejb-name>
<ejb-class>net.viewerapp.coreservices.jobs.impl.ScheduleServiceQueueHandlerBean</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
</message-driven>

In jboss.xml:

<message-driven>
<ejb-name>ScheduleServiceQueueHandler</ejb-name>
<destination-jndi-name>queue/schedServiceQueue</destination-jndi-name>
</message-driven>

In myqueue-service.xml:

<mbean code="org.jboss.mq.server.jmx.Queue"
name="jboss.mq.destination:service=Queue,name=schedServiceQueue">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager</depends>
</mbean>

Thanks in advance for any help you can offer!


Vanessa<br />SCJP,SCJD,IBM OOAD w/UML,Project+
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

When I send a message to the queue, JBoss creates 11 instances of my message-driven bean and onMessage is invoked on all of them.




How is that possible ? A message in a queue can be consumed by only one client.


Groovy
Thomas Mechlinski
Greenhorn

Joined: Dec 16, 2004
Posts: 1
Hi,

I had the same problem. The MDB instances are held in a pool. JBossMQ starts a number of them when the MDB reads in the queue. The number of instances can be customized in

$JBOSS_HOME/server/<server-name>/conf/standardjboss.xml

Search for

ServerSessionPoolFactoryJNDI

and adjust the MaximumSize property to the appropriate value (can be 1, than only one instance is active):

<MaximumSize>1</MaximumSize>

This solved my problem - hope it will work for you, too.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMS and instance pool of msg driven beans