[JBoss Messaging] - Re: Removing a MessageListener doesn't remove its associated
by davidrh
I've updated the test harness and I can reproduce both problems - the increasing number of threads and the NotFoundInDispatcherException. From my testing it seems that once a thread in the pool has received a message, it is never destroyed but also is never allocated to another message listener. In this way, the number of threads slowly builds up over time, as the thread pool doesn't seem to count these threads as being part of the pool anymore. You can see this behaviour if you produced messages at a slower rate than the consumers are consuming them. The threads that have consumed messages will never be destroyed, and those that haven't will get destroyed after a certain amount of time (seems to be around 1 minute).
The NotFoundInDispatcherException seems to be caused by setting the message listener to null to try and de-register it. According to the API http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/MessageConsumer.h... this should have the effect of unsetting the listener for the message consumer. This doesn't worry me much, as I'll simply stop doing it - I was only doing it to see if it removed the threads more cleanly.
You need to run this against a queue that has lots of text messages in it for this harness to consume.
I've made the harness do exactly what we're doing in our application, which is receive a message from one queue and place a message on another queue. In this case, the placing of the message on the other queue doesn't seem to influence the above behaviour.
| public class TestMultiSessionMessageListener {
|
| public static void main(String[] args) {
| TestMultiSessionMessageListener ml = new TestMultiSessionMessageListener();
|
| try {
| ml.test();
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
|
| private void test() throws Exception {
| Hashtable properties = new Hashtable();
| properties.put(Context.INITIAL_CONTEXT_FACTORY,
| "org.jnp.interfaces.NamingContextFactory");
| properties.put(Context.URL_PKG_PREFIXES,
| "org.jboss.naming:org.jnp.interfaces");
| properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
| properties.put(Context.SECURITY_PRINCIPAL, "admin");
| properties.put(Context.SECURITY_CREDENTIALS, "admin");
|
| ConnectionFactory connectionFactory = null;
|
| try {
| Context context = new InitialContext(properties);
| connectionFactory = (ConnectionFactory) context
| .lookup("ConnectionFactory");
| } catch (NamingException ne) {
| throw new RuntimeException(ne);
| }
|
| Connection connection = connectionFactory.createConnection();
| connection.start();
|
| // We want to have 5 threads listening for messages
| int numberOfProcesses = 5;
|
| MessageConsumer[] consumers = new MessageConsumer[numberOfProcesses];
| Session[] sessions = new Session[numberOfProcesses];
|
| while (true) {
| for (int j = 0; j < consumers.length; j++) {
| sessions[j] = connection.createSession(false,
| Session.AUTO_ACKNOWLEDGE);
| final Queue sourceQ = sessions[j].createQueue("publish.request");
| final Queue destQ = sessions[j]
| .createQueue("publish.request.error");
| final Session session = sessions[j];
|
| consumers[j] = sessions[j].createConsumer(sourceQ);
| MessageListener ml = new MessageListener() {
|
| public void onMessage(Message msg) {
| try {
| String payload = ((TextMessage) msg).getText();
| System.out.println(Thread.currentThread().getName()
| + " " + payload);
| MessageProducer producer = session
| .createProducer(destQ);
| producer.send(msg);
| try {
| // Simulate normal processing time
| Thread.currentThread().sleep(500);
| } catch (InterruptedException e) {
| e.printStackTrace();
| }
| } catch (JMSException e) {
| e.printStackTrace();
| }
| }
| };
|
| consumers[j].setMessageListener(ml);
| }
|
| // Recycle the sessions every 60 seconds
| Thread.sleep(60000);
| for (int j = 0; j < consumers.length; j++) {
| try {
| consumers[j].setMessageListener(null);
| consumers[j].close();
| } catch (Exception e) {
| // Ignore as we are recycling it anyway
| e.printStackTrace();
| }
| consumers[j] = null;
| try {
| sessions[j].close();
| } catch (Exception e) {
| // Ignore as we are recycling it anyway
| e.printStackTrace();
| }
| sessions[j] = null;
| }
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961768#3961768
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961768
17 years, 11 months
[JBoss Seam] - conversation timeout
by goose-dog
Hi, has anyone had this problem?
My conversations never timeout. Only when my session timeout do my conversations timeout too.
Here is my components.xml, conversation should timeout in 2 minutes, but it took 30 minutes(my session timeout).
| <components>
|
| <component name="org.jboss.seam.core.init">
| <property name="myFacesLifecycleBug">@myFacesLifecycleBug@</property>
| <property name="jndiPattern">@jndiPattern@</property>
| </component>
|
| <!-- 120 second conversation timeout -->
| <component name="org.jboss.seam.core.manager">
| <property name="conversationTimeout">120000</property>
| </component>
|
| <component class="org.jboss.seam.core.Jbpm">
| <property name="pageflowDefinitions">newUser.jpdl.xml</property>
| </component>
|
| <component class="org.jboss.seam.core.Ejb"
| installed="@embeddedEjb@"/>
|
| </components>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961767#3961767
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961767
17 years, 11 months
[Beginners Corner] - Class path issues
by wichka
When I create a new jboss instance and put jar files under lib directory and sar file under deploy and service gets deployed fine. But the service looks for the configuration file abc.xml in the class path( by getting class loader and trying to load it). Where should I put this configuration file so that service can find it in the class path of the instance?
I tried putting the abc.xml in the conf diretory, service can't find it in the classpath. I tried putting it in the lib directotory, service can't find it. I can't jar up the xml file with the jar file because it needs to be in area where I can change it if needed.
Could you please help. This is a basic questions. I am new to Jboss and don't have good hold on Jboss class loading mechanism.
Thanks,
Bashir Wichka
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961760#3961760
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961760
17 years, 11 months