use of org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin 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;
}
use of org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin in project activemq-artemis by apache.
the class CriticalSimpleTest method testSimpleShutdown.
@Test
public void testSimpleShutdown() throws Exception {
Configuration configuration = createDefaultConfig(false);
configuration.setCriticalAnalyzerCheckPeriod(10).setCriticalAnalyzerPolicy(CriticalAnalyzerPolicy.SHUTDOWN);
ActiveMQServer server = createServer(false, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES);
server.start();
try {
CountDownLatch latch = new CountDownLatch(1);
server.getConfiguration().registerBrokerPlugin(new ActiveMQServerPlugin() {
@Override
public void criticalFailure(CriticalComponent components) throws ActiveMQException {
latch.countDown();
}
});
server.getCriticalAnalyzer().add(new CriticalComponent() {
@Override
public boolean isExpired(long timeout) {
return true;
}
});
Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
Wait.waitFor(() -> !server.isStarted());
Assert.assertFalse(server.isStarted());
} finally {
server.stop();
}
}
Aggregations