MessageConsumer durable1 = sess1.createDurableSubscriber(topic, "mySubscription1"); MessageConsumer durable2 = sess1.createDurableSubscriber(topic, "mySubscription2");
sess1.createDurableSubscriber(topic, "mySubscription1"); sess1.createDurableSubscriber(topic, "mySubscription2");
   public void testDurableSubscriptionMultipleSubscriptions() throws Exception   {      final String CLIENT_ID1 = "test-client-id1";      Connection conn1 = null;      Connection conn2 = null;            try      {                  conn1 = cf.createConnection();            conn1.setClientID(CLIENT_ID1);            Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);            MessageConsumer durable1 = sess1.createDurableSubscriber(topic, "mySubscription1");         MessageConsumer durable2 = sess1.createDurableSubscriber(topic, "mySubscription2");                        conn1.close();                                    conn2 = cf.createConnection();         conn2.setClientID(CLIENT_ID1);         Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageProducer producer = sess2.createProducer(topic);         producer.setDeliveryMode(DeliveryMode.PERSISTENT);            final int NUM_MESSAGES = 50;             for (int i = 0; i < NUM_MESSAGES; i++)         {            TextMessage tm = sess2.createTextMessage("hello");            producer.send(tm);         }                  sess2.unsubscribe("mySubscription1");                  conn2.close();                                             Connection conn3 = cf.createConnection();         conn3.setClientID(CLIENT_ID1);         conn3.start();         Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageConsumer durable3 = sess3.createDurableSubscriber(topic, "mySubscription2");                  int count = 0;         while (true)         {            TextMessage tm = (TextMessage)durable3.receive(1000);            if (tm == null)            {               break;            }            assertEquals("hello", tm.getText());            count++;         }                  assertEquals(NUM_MESSAGES, count);                  MessageConsumer durable4 = sess3.createDurableSubscriber(topic, "mySubscription1");                  Message m = durable4.receive(1000);         assertNull(m);      }      finally      {         if (conn1 != null)         {            conn1.close();         }         if (conn2 != null)         {            conn2.close();         }      }         }