use of org.apache.activemq.artemis.core.protocol.stomp.StompConnection in project activemq-artemis by apache.
the class StompPluginTest method createServer.
@Override
protected JMSServerManager createServer() throws Exception {
JMSServerManager server = super.createServer();
server.getActiveMQServer().registerBrokerPlugin(verifier);
server.getActiveMQServer().registerBrokerPlugin(new ActiveMQServerPlugin() {
@Override
public void beforeCreateSession(String name, String username, int minLargeMessageSize, RemotingConnection connection, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, boolean xa, String defaultAddress, SessionCallback callback, boolean autoCreateQueues, OperationContext context, Map<SimpleString, RoutingType> prefixes) throws ActiveMQException {
if (connection instanceof StompConnection) {
stompBeforeCreateSession.set(true);
}
}
@Override
public void beforeCloseSession(ServerSession session, boolean failed) throws ActiveMQException {
if (session.getRemotingConnection() instanceof StompConnection) {
stompBeforeRemoveSession.set(true);
}
}
});
return server;
}
use of org.apache.activemq.artemis.core.protocol.stomp.StompConnection in project activemq-artemis by apache.
the class StompV11Test method testHeartBeat3.
@Test
public void testHeartBeat3() throws Exception {
connection.close();
ClientStompFrame frame = conn.createFrame("CONNECT");
frame.addHeader("host", "127.0.0.1");
frame.addHeader("login", this.defUser);
frame.addHeader("passcode", this.defPass);
frame.addHeader("heart-beat", "500,500");
frame.addHeader("accept-version", "1.0,1.1");
ClientStompFrame reply = conn.sendFrame(frame);
assertEquals("CONNECTED", reply.getCommand());
assertEquals("500,500", reply.getHeader("heart-beat"));
System.out.println("========== start pinger!");
conn.startPinger(100);
Assert.assertEquals(1, server.getActiveMQServer().getRemotingService().getConnections().size());
StompConnection stompConnection = (StompConnection) server.getActiveMQServer().getRemotingService().getConnections().iterator().next();
StompFrameHandlerV11 stompFrameHandler = (StompFrameHandlerV11) stompConnection.getStompVersionHandler();
Thread.sleep(1000);
// now check the frame size
int size = conn.getServerPingNumber();
conn.stopPinger();
// ((AbstractStompClientConnection)conn).killReaderThread();
Wait.waitFor(() -> {
return server.getActiveMQServer().getRemotingService().getConnections().size() == 0;
});
Assert.assertFalse(stompFrameHandler.getHeartBeater().isStarted());
}
use of org.apache.activemq.artemis.core.protocol.stomp.StompConnection in project activemq-artemis by apache.
the class MyStompInterceptor method intercept.
@Override
public boolean intercept(StompFrame frame, RemotingConnection remotingConnection) throws ActiveMQException {
StompConnection connection = (StompConnection) remotingConnection;
frame.addHeader("stompIntercepted", "Hello");
System.out.println("MyStompInterceptor Intercepted frame " + frame + " on connection " + connection);
return true;
}
Aggregations