use of org.apache.activemq.transport.TransportAcceptListener in project activemq-artemis by apache.
the class TcpTransportServerTest method testDefaultPropertiesSetOnTransport.
public void testDefaultPropertiesSetOnTransport() throws Exception {
TcpTransportServer server = (TcpTransportServer) TransportFactory.bind(new URI("tcp://localhost:61616?trace=true"));
server.setTransportOption(new HashMap<String, Object>());
server.setAcceptListener(new TransportAcceptListener() {
@Override
public void onAccept(Transport transport) {
assertTrue("This transport does not have a TransportLogger!!", hasTransportLogger(transport));
}
@Override
public void onAcceptError(Exception error) {
fail("Should not have received an error!");
}
});
server.start();
Socket socket = new Socket("localhost", 61616);
server.handleSocket(socket);
server.stop();
}
use of org.apache.activemq.transport.TransportAcceptListener in project activemq-artemis by apache.
the class UdpTestSupport method setUp.
@Override
protected void setUp() throws Exception {
server = createServer();
if (server != null) {
server.setAcceptListener(new TransportAcceptListener() {
@Override
public void onAccept(Transport transport) {
consumer = transport;
consumer.setTransportListener(UdpTestSupport.this);
try {
consumer.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void onAcceptError(Exception error) {
}
});
server.start();
}
consumer = createConsumer();
if (consumer != null) {
consumer.setTransportListener(this);
consumer.start();
}
producer = createProducer();
producer.setTransportListener(new TransportListener() {
@Override
public void onCommand(Object command) {
LOG.info("Producer received: " + command);
}
@Override
public void onException(IOException error) {
LOG.info("Producer exception: " + error);
error.printStackTrace();
}
@Override
public void transportInterupted() {
}
@Override
public void transportResumed() {
}
});
producer.start();
}
use of org.apache.activemq.transport.TransportAcceptListener 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();
}
Aggregations