Please say what version of JBM, AS you are using and post your code.
I am not sure what JBM is but I am running jdk1.5.0_10, JBoss 4.0.5 GA, and Messaging 1.0.1GA. It would be difficult to post my actual code in this forum but it is essentially executing the following in the onMessage().
Properties p = new Properties ();
p.put (Context.PROVIDER_URL, "jnp://localhost:1099");
p.put (Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put (Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
InitialContext context = new InitialContext (p);
MessageConsumer consumer = null;
int count = 0;
Queue queue = (Queue) context.lookup (queuename);
consumer = jmssession.createConsumer (queue);
... do something here
catch (Exception e)
System.err.println( "Exception while trying to clear error queue");
I verified that the createConsumer line is where the thread is being created and the thread remains when I undeploy my service. Each time a message goes through a new thread is created that never goes away.
JBM is JBoss Messaging.
Are your jms client and jms server running in the same VM?
Threads for server side consumers are taken from a server side "pool" which has a default max size of 200.
How many threads are you seeing?
If 200 is too high for you, you can reduce the number by adding an attribute QueuedExecutorPoolSize on the serverpeer specifying the max size you want.
Yes, my mbean that is servicing my jms queues is running in the same jvm as the messaging service, that is, the mbean is deployed in the same default server that is running messaging.
So if I understand you correctly, the thread count will continue to grow until it reaches 200 then it will begin to reuse the consumer threads?
Forgive my ignorance but I am new to JBoss. To make it absolutely clear for me, and any other noobs interested, are you saying that in order to change this (for example to 50) I would add:
to messaging-service.xml under the ServerBean mbean?
Thanks for your rapid response.
Yes, add an attribute:
in the server peer mbean config