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");
}
}
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;
}
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);
}
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;
}
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;
}
Aggregations