TopicSubscriber.close() hanging (with test case)
DATACOM - Diego <diego-lTwzwfQtfhvIp6JUJ/xx9mp/[email protected]>
| Newsgroups | gmane.comp.java.openjms.user |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
we are using Java 1.5.0_02, OpenJMS 0.7.6.1, TCP connections.
We have been facing a server hanging problem similar to some described
in this mailing list (see end of the message). The problem seems to be
that a TopicSubscriber can not be closed while it is processing some
message. When that happens, the client thread will hang on
TopicSubscriber.close() and the server will not accept any new
subscribers (any call to TopicSession.createSubscriber() will hang too).
Apparently, subscribers created before that continue to work normally.
The error occurred on 90% of the simulations while running the two
pieces of code below. The machine was a Intel Celeron 2GHz 512Mb,
running WindowsXP, using Eclipse. The server was running on the same
machine of the two client applications. (Factory, connection and session
creation code was suppressed.)
JmsSenderTest:
public class JmsSenderTest {
public static void main(String[] args) throws Exception {
TopicPublisher publisher = getPublisher();
System.out.println("Started...");
for (int i = 0; i < 5000; i++) {
Message msg = getSession().createMessage();
publisher.publish(msg);
System.out.println("Sent msg " + i);
try {Thread.sleep(25L);} catch (InterruptedException exc) {}
}
System.out.println("Finished.");
}
}
JmsReceiverTest:
public class JmsReceiverTest implements MessageListener {
public static void main(String[] args) throws Exception {
JmsReceiverTest listen = new JmsReceiverTest();
System.out.println("Started...");
for (int i = 0; i < 50; i++) {
TopicSubscriber subscriber = getSubscriber();
subscriber.setMessageListener(listen);
System.out.println("Just after creation " + i);
try {Thread.sleep(250L);} catch (InterruptedException exc) {}
subscriber.close();
System.out.println("Just after close " + i);
try {Thread.sleep(250L);} catch (InterruptedException exc) {}
}
System.out.println("Finished.");
}
public void onMessage(Message msg) {
System.out.println("onMessage");
}
}
The steps are:
1. run JmsSenderTest (starts sending messages);
2. run JmsReceiverTest (starts opening and closing subscribers);
3. JmsReceiverTest blocks on subscriber.close() before completing the 50
iterations;
4. run another instance of JmsReceiverTest;
5. the second instance of JmsReceiverTest blocks on getSubscriber();
6. kill the JVM of the first instance of JmsReceiverTest;
7. the second instance of JmsReceiverTest unblocks.
Is there any workaround for this? I have seen some topics related to
this on the list archives:
http://sourceforge.net/mailarchive/message.php?msg_id=9184772
http://sourceforge.net/mailarchive/message.php?msg_id=9036096
http://sourceforge.net/mailarchive/message.php?msg_id=9368056
http://sourceforge.net/mailarchive/message.php?msg_id=11414404
http://sourceforge.net/mailarchive/message.php?msg_id=11415200
Thanx in advance,
--
DIEGO Moreira da Rosa
DATACOM
Av França, 735 - Porto Alegre, RS - 90230-220
DDR: 51 3358 0141
Fax: 51 3358 0101
site: www.datacom-telematica.com.br
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click