use of org.hornetq.jms.client.HornetQQueue in project eap-additional-testsuite by jboss-set.
the class HornetQServerManagementTestCase method testCloseConsumerConnectionsForAddress.
@Test
public void testCloseConsumerConnectionsForAddress() throws Exception {
JMSOperations adminSupport = JMSOperationsProvider.getInstance(managementClient);
adminSupport.createJmsQueue(getQueueName(), getQueueJndiName());
Connection connection = connectionFactory.createConnection("guest", "guest");
HornetQQueue queue = HornetQDestination.createQueue(getQueueName());
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queue);
connection.start();
final CountDownLatch connectionClosed = new CountDownLatch(1);
connection.setExceptionListener(new ExceptionListener() {
@Override
public void onException(JMSException e) {
System.out.println("HornetQServerManagementTestCase.onException");
connectionClosed.countDown();
}
});
ModelNode operation = getHornetQServerOperation("close-consumer-connections-for-address");
operation.get("address-match").set("jms.#");
System.out.println("operation = " + operation);
ModelNode result = execute(operation, true);
System.out.println("result = " + result);
assertTrue(result.isDefined());
assertEquals(true, result.asBoolean());
assertTrue(connectionClosed.await(500, MILLISECONDS));
// consumer is no longer valid
try {
consumer.receiveNoWait();
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Assert.fail("consumer can no longer be used after it has been closed");
} catch (JMSException e) {
}
// connection is no longer valid
try {
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Assert.fail("connection can no longer be used after it has been closed");
} catch (JMSException e) {
}
}
Aggregations