JBMESSAGING-541 - Multiple connections on a single thread wi
clebert.suconic Sep 8, 2006 6:34 PMI"ve opened this thread to discuss the creationg of DurableCrashTest1 and DurableCrashTest2.
If I have a client with two connections opened (don't know if the fact they are in the same thread matters or not), the lease timer stops and never comes back.
I've discovered this by adding a couple of log.info into JBossRemoting during leasing and stop leasing. And basically, during addCallBAck a new client is created/closed what stops the lease timer.
What is funny is with a single connection test, this works fine. (I mean the connection is detected without any problem)
I have also opened a JIRA on JBossRemoting:
http://jira.jboss.org/jira/browse/JBREM-596
public void testSimplestDurableSubscription() throws Exception { ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory"); Topic topic = (Topic)ic.lookup("/topic/TopicCrash"); Connection conn = cf.createConnection(); conn.setClientID("client1"); conn.start(); Connection conn2 = cf.createConnection(); // funny... if I remove everything related to conn2, the lease thread works conn2.setClientID("client2"); conn2.start(); Session s = conn.createSession(true, Session.AUTO_ACKNOWLEDGE); Session s2 = conn2.createSession(true, Session.AUTO_ACKNOWLEDGE); MessageProducer prod = s.createProducer(topic); prod.setDeliveryMode(DeliveryMode.PERSISTENT); MessageConsumer durable = s.createDurableSubscriber(topic, "subs1"); MessageConsumer durable2 = s2.createDurableSubscriber(topic, "subs2"); //conn2.close(); -- do not remote this comment. It was meant to not close the connection for (int i=0;i<10;i++) { prod.send(s.createTextMessage("k"+i)); } s.commit(); conn.close(); conn = cf.createConnection(); conn.setClientID("client1"); conn.start(); s = conn.createSession(true, Session.AUTO_ACKNOWLEDGE); durable = s.createDurableSubscriber(topic, "subs1"); for (int i=0;i<2;i++) { TextMessage tm = (TextMessage)durable.receive(1000); assertNotNull(tm); s.commit(); System.out.println(tm.getText()); assertEquals("k" + i, tm.getText()); } //conn.close();-- do not remote this comment. It was meant to not close the connection //System.exit(0); -- this is not needed as there is not tearDown, the client VM will simply be finished the same way an exit would do, and this is better since it will keep proper JUNIT report outputs }