Search in sources :

Example 6 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)

Example 7 with WireFormatInfo

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

the class WireFormatInfoData method createObject.

@Override
protected Object createObject() throws IOException {
    WireFormatInfo rc = new WireFormatInfo();
    rc.setResponseRequired(false);
    rc.setCacheEnabled(true);
    rc.setVersion(1);
    return rc;
}
Also used : WireFormatInfo(org.apache.activemq.command.WireFormatInfo)

Example 8 with WireFormatInfo

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

the class OpenWireConnection method reconnect.

// raise the refCount of context
public void reconnect(AMQConnectionContext existingContext, ConnectionInfo info) {
    this.context = existingContext;
    WireFormatInfo wireFormatInfo = inWireFormat.getPreferedWireFormatInfo();
    // they were not.
    if (wireFormatInfo != null && wireFormatInfo.getVersion() <= 2) {
        info.setClientMaster(true);
    }
    if (info.getClientIp() == null) {
        info.setClientIp(getRemoteAddress());
    }
    state = new ConnectionState(info);
    state.reset(info);
    context.setConnection(this);
    context.setConnectionState(state);
    context.setClientMaster(info.isClientMaster());
    context.setFaultTolerant(info.isFaultTolerant());
    context.setReconnect(true);
    context.incRefCount();
}
Also used : WireFormatInfo(org.apache.activemq.command.WireFormatInfo) ConnectionState(org.apache.activemq.state.ConnectionState)

Example 9 with WireFormatInfo

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

the class WireFormatInfoTest method createObject.

@Override
public Object createObject() throws Exception {
    WireFormatInfo info = new WireFormatInfo();
    populateObject(info);
    return info;
}
Also used : WireFormatInfo(org.apache.activemq.command.WireFormatInfo)

Example 10 with WireFormatInfo

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

the class WireformatNegociationTest method startServer.

/**
 * @throws IOException
 * @throws URISyntaxException
 * @throws Exception
 */
private void startServer(String uri) throws IOException, URISyntaxException, Exception {
    server = TransportFactory.bind(new URI(uri));
    server.setAcceptListener(new TransportAcceptListener() {

        @Override
        public void onAccept(Transport transport) {
            try {
                LOG.info("[" + getName() + "] Server Accepted a Connection");
                serverTransport = transport;
                serverTransport.setTransportListener(new TransportListener() {

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

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

                    @Override
                    public void transportInterupted() {
                    }

                    @Override
                    public void transportResumed() {
                    }
                });
                serverTransport.start();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onAcceptError(Exception error) {
            error.printStackTrace();
        }
    });
    server.start();
}
Also used : TransportListener(org.apache.activemq.transport.TransportListener) WireFormatInfo(org.apache.activemq.command.WireFormatInfo) IOException(java.io.IOException) Transport(org.apache.activemq.transport.Transport) URI(java.net.URI) TransportAcceptListener(org.apache.activemq.transport.TransportAcceptListener) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

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