return;
}
final String SUB_NAME=getTestQueueName();
TopicConnectionFactory factory = getConnectionFactory();
Topic topic = (Topic) getInitialContext().lookup(_topicName);
//create and register a durable subscriber then unsubscribe it
TopicConnection durConnection = factory.createTopicConnection("guest", "guest");
TopicSession durSession = durConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
TopicSubscriber durSub1 = durSession.createDurableSubscriber(topic, SUB_NAME);
durConnection.start();
durSub1.close();
durSession.unsubscribe(SUB_NAME);
durSession.close();
durConnection.close();
//create and register a durable subscriber with a message selector and then close it
TopicConnection durConnection2 = factory.createTopicConnection("guest", "guest");
TopicSession durSession2 = durConnection2.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
TopicSubscriber durSub2 = durSession2.createDurableSubscriber(topic, SUB_NAME, "testprop='true'", false);
durConnection2.start();
durSub2.close();
durSession2.close();
durConnection2.close();
//now restart the server
try
{
restartBroker();
}
catch (Exception e)
{
_logger.error("problems restarting broker: " + e);
throw e;
}
//send messages matching and not matching the selector
TopicConnection pubConnection = factory.createTopicConnection("guest", "guest");
TopicSession pubSession = pubConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
TopicPublisher publisher = pubSession.createPublisher(topic);
for (int i = 0; i < 5; i++)
{
Message message = pubSession.createMessage();
message.setStringProperty("testprop", "true");
publisher.publish(message);
message = pubSession.createMessage();
message.setStringProperty("testprop", "false");
publisher.publish(message);
}
publisher.close();
pubSession.close();
//now recreate the durable subscriber with selector to check there are no exceptions generated
//and then verify the messages are received correctly
TopicConnection durConnection3 = (TopicConnection) factory.createConnection("guest", "guest");
TopicSession durSession3 = (TopicSession) durConnection3.createSession(false, Session.AUTO_ACKNOWLEDGE);
TopicSubscriber durSub3 = durSession3.createDurableSubscriber(topic, SUB_NAME, "testprop='true'", false);
durConnection3.start();
for (int i = 0; i < 5; i++)