Search in sources :

Example 1 with WireFormatInfo

use of org.apache.activemq.command.WireFormatInfo in project jim-framework by jiangmin168168.

the class ConsumerConnctionFactory method onCommand.

@Override
public void onCommand(Object o) {
    if (o instanceof BrokerInfo) {
        BrokerInfo brokerInfo = (BrokerInfo) o;
        System.out.println("onCommand" + brokerInfo.getBrokerURL());
        ConnectionFactoryContainer.addBrokerConnection(brokerInfo.getBrokerURL(), brokerInfo.getBrokerId() + "");
        if (connectionCount.containsKey(brokerInfo.getBrokerURL())) {
            connectionCount.get(brokerInfo.getBrokerURL()).incrementAndGet();
        } else {
            connectionCount.put(brokerInfo.getBrokerURL(), new AtomicLong(1));
        }
    } else if (o instanceof WireFormatInfo) {
        WireFormatInfo wireFormatInfo = (WireFormatInfo) o;
        System.out.println("onCommand WireFormatInfo");
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) WireFormatInfo(org.apache.activemq.command.WireFormatInfo) BrokerInfo(org.apache.activemq.command.BrokerInfo)

Example 2 with WireFormatInfo

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

the class OpenWireConnection method initContext.

public AMQConnectionContext initContext(ConnectionInfo info) throws Exception {
    WireFormatInfo wireFormatInfo = inWireFormat.getPreferedWireFormatInfo();
    // they were not.
    if (wireFormatInfo != null && wireFormatInfo.getVersion() <= 2) {
        info.setClientMaster(true);
    }
    state = new ConnectionState(info);
    context = new AMQConnectionContext();
    state.reset(info);
    // Setup the context.
    String clientId = info.getClientId();
    context.setBroker(protocolManager);
    context.setClientId(clientId);
    context.setClientMaster(info.isClientMaster());
    context.setConnection(this);
    context.setConnectionId(info.getConnectionId());
    // for now we pass the manager as the connector and see what happens
    // it should be related to activemq's Acceptor
    context.setFaultTolerant(info.isFaultTolerant());
    context.setUserName(info.getUserName());
    context.setWireFormatInfo(wireFormatInfo);
    context.setReconnect(info.isFailoverReconnect());
    context.setConnectionState(state);
    if (info.getClientIp() == null) {
        info.setClientIp(getRemoteAddress());
    }
    createInternalSession(info);
    return context;
}
Also used : AMQConnectionContext(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext) WireFormatInfo(org.apache.activemq.command.WireFormatInfo) ConnectionState(org.apache.activemq.state.ConnectionState) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 3 with WireFormatInfo

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

the class OpenWireConnection method sendHandshake.

// send a WireFormatInfo to the peer
public void sendHandshake() {
    WireFormatInfo info = inWireFormat.getPreferedWireFormatInfo();
    sendCommand(info);
}
Also used : WireFormatInfo(org.apache.activemq.command.WireFormatInfo)

Example 4 with WireFormatInfo

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

the class OpenWireProtocolManager method isProtocol.

@Override
public boolean isProtocol(byte[] array) {
    if (array.length < 8) {
        throw new IllegalArgumentException("Protocol header length changed " + array.length);
    }
    int start = this.prefixPacketSize ? 4 : 0;
    int j = 0;
    // type
    if (array[start] != WireFormatInfo.DATA_STRUCTURE_TYPE) {
        return false;
    }
    start++;
    WireFormatInfo info = new WireFormatInfo();
    final byte[] magic = info.getMagic();
    int remainingLen = array.length - start;
    int useLen = remainingLen > magic.length ? magic.length : remainingLen;
    useLen += start;
    // magic
    for (int i = start; i < useLen; i++) {
        if (array[i] != magic[j]) {
            return false;
        }
        j++;
    }
    return true;
}
Also used : WireFormatInfo(org.apache.activemq.command.WireFormatInfo)

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

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