Search in sources :

Example 11 with WireFormatInfo

use of org.apache.activemq.command.WireFormatInfo in project activemq-artemis by apache.

the class WireformatNegociationTest method startClient.

/**
 * @throws Exception
 * @throws URISyntaxException
 */
private void startClient(String uri) throws Exception, URISyntaxException {
    clientTransport = TransportFactory.connect(new URI(uri));
    clientTransport.setTransportListener(new TransportListener() {

        @Override
        public void onCommand(Object command) {
            if (command instanceof WireFormatInfo) {
                clientWF.set((WireFormatInfo) command);
                negotiationCounter.countDown();
            }
        }

        @Override
        public void onException(IOException error) {
            if (!ignoreAsycError.get()) {
                LOG.info("Client transport error: ", error);
                asyncError.set(error);
                negotiationCounter.countDown();
            }
        }

        @Override
        public void transportInterupted() {
        }

        @Override
        public void transportResumed() {
        }
    });
    clientTransport.start();
}
Also used : TransportListener(org.apache.activemq.transport.TransportListener) WireFormatInfo(org.apache.activemq.command.WireFormatInfo) IOException(java.io.IOException) URI(java.net.URI)

Example 12 with WireFormatInfo

use of org.apache.activemq.command.WireFormatInfo in project activemq-artemis by apache.

the class InactivityMonitorTest method testClientHang.

public void testClientHang() throws Exception {
    // Manually create a client transport so that it does not send KeepAlive
    // packets.  this should simulate a client hang.
    clientTransport = new TcpTransport(new OpenWireFormat(), SocketFactory.getDefault(), new URI("tcp://localhost:" + serverPort), null);
    clientTransport.setTransportListener(new TransportListener() {

        @Override
        public void onCommand(Object command) {
            clientReceiveCount.incrementAndGet();
            if (clientRunOnCommand != null) {
                clientRunOnCommand.run();
            }
        }

        @Override
        public void onException(IOException error) {
            if (!ignoreClientError.get()) {
                LOG.info("Client transport error:");
                error.printStackTrace();
                clientErrorCount.incrementAndGet();
            }
        }

        @Override
        public void transportInterupted() {
        }

        @Override
        public void transportResumed() {
        }
    });
    clientTransport.start();
    WireFormatInfo info = new WireFormatInfo();
    info.setVersion(OpenWireFormat.DEFAULT_LEGACY_VERSION);
    info.setMaxInactivityDuration(1000);
    clientTransport.oneway(info);
    assertEquals(0, serverErrorCount.get());
    assertEquals(0, clientErrorCount.get());
    // Server should consider the client timed out right away since the
    // client is not hart beating fast enough.
    Thread.sleep(6000);
    assertEquals(0, clientErrorCount.get());
    assertTrue(serverErrorCount.get() > 0);
}
Also used : OpenWireFormat(org.apache.activemq.openwire.OpenWireFormat) TransportListener(org.apache.activemq.transport.TransportListener) WireFormatInfo(org.apache.activemq.command.WireFormatInfo) IOException(java.io.IOException) URI(java.net.URI)

Example 13 with WireFormatInfo

use of org.apache.activemq.command.WireFormatInfo in project activemq-artemis by apache.

the class WireFormatInfoTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    WireFormatInfo info = (WireFormatInfo) object;
    info.setVersion(1);
    {
        byte[] data = "MarshalledProperties:1".getBytes();
        info.setMarshalledProperties(new org.apache.activemq.util.ByteSequence(data, 0, data.length));
    }
}
Also used : WireFormatInfo(org.apache.activemq.command.WireFormatInfo)

Aggregations

WireFormatInfo (org.apache.activemq.command.WireFormatInfo)13 IOException (java.io.IOException)3 URI (java.net.URI)3 TransportListener (org.apache.activemq.transport.TransportListener)3 ConnectionState (org.apache.activemq.state.ConnectionState)2 URISyntaxException (java.net.URISyntaxException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 AMQConnectionContext (org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext)1 BrokerInfo (org.apache.activemq.command.BrokerInfo)1 OpenWireFormat (org.apache.activemq.openwire.OpenWireFormat)1 Transport (org.apache.activemq.transport.Transport)1 TransportAcceptListener (org.apache.activemq.transport.TransportAcceptListener)1