use of org.apache.activemq.artemis.core.server.ServerSession in project activemq-artemis by apache.
the class ActiveMQServerControlTest method testCloseCOREclient.
@Test
public void testCloseCOREclient() throws Exception {
SimpleString address = RandomUtil.randomSimpleString();
SimpleString name = RandomUtil.randomSimpleString();
boolean durable = true;
ActiveMQServerControl serverControl = createManagementControl();
checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
serverControl.createAddress(address.toString(), "ANYCAST");
serverControl.createQueue(address.toString(), "ANYCAST", name.toString(), null, durable, -1, false, false);
ServerLocator receiveLocator = createInVMNonHALocator();
ClientSessionFactory receiveCsf = createSessionFactory(receiveLocator);
ClientSession receiveClientSession = receiveCsf.createSession(true, false, false);
final ClientConsumer COREclient = receiveClientSession.createConsumer(name);
ServerSession ss = server.getSessions().iterator().next();
ServerConsumer sc = ss.getServerConsumers().iterator().next();
Assert.assertFalse(COREclient.isClosed());
serverControl.closeConsumerWithID(((ClientSessionImpl) receiveClientSession).getName(), Long.toString(sc.sequentialID()));
Wait.waitFor(() -> COREclient.isClosed());
Assert.assertTrue(COREclient.isClosed());
}
use of org.apache.activemq.artemis.core.server.ServerSession in project activemq-artemis by apache.
the class SessionMetadataAddExceptionTest method createDefaultConfig.
@Override
protected Configuration createDefaultConfig(boolean netty) throws Exception {
Configuration config = super.createDefaultConfig(netty);
config.registerBrokerPlugin(new ActiveMQServerPlugin() {
@Override
public void beforeSessionMetadataAdded(ServerSession session, String key, String data) throws ActiveMQException {
if (ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY.equals(key)) {
if ("invalid".equals(data)) {
throw new ActiveMQException("Invalid clientId");
}
}
}
});
return config;
}
Aggregations