Search in sources :

Example 1 with StompConnection

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;
}
Also used : OperationContext(org.apache.activemq.artemis.core.persistence.OperationContext) JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager) ServerSession(org.apache.activemq.artemis.core.server.ServerSession) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SessionCallback(org.apache.activemq.artemis.spi.core.protocol.SessionCallback) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin) StompConnection(org.apache.activemq.artemis.core.protocol.stomp.StompConnection) RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Example 2 with StompConnection

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());
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) StompConnection(org.apache.activemq.artemis.core.protocol.stomp.StompConnection) StompFrameHandlerV11(org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11) Test(org.junit.Test)

Example 3 with StompConnection

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;
}
Also used : StompConnection(org.apache.activemq.artemis.core.protocol.stomp.StompConnection)

Aggregations

StompConnection (org.apache.activemq.artemis.core.protocol.stomp.StompConnection)3 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 OperationContext (org.apache.activemq.artemis.core.persistence.OperationContext)1 StompFrameHandlerV11 (org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11)1 ServerSession (org.apache.activemq.artemis.core.server.ServerSession)1 ActiveMQServerPlugin (org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin)1 JMSServerManager (org.apache.activemq.artemis.jms.server.JMSServerManager)1 RemotingConnection (org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)1 SessionCallback (org.apache.activemq.artemis.spi.core.protocol.SessionCallback)1 ClientStompFrame (org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame)1 Test (org.junit.Test)1