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