use of org.apache.activemq.transport.Transport 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();
}
use of org.apache.activemq.transport.Transport in project activemq-artemis by apache.
the class FailoverTransportBackupsTest method createTransport.
protected Transport createTransport(int backups) throws Exception {
String connectionUri = "failover://(" + newURI(0) + "," + newURI(1) + "," + newURI(2) + ")";
if (backups > 0) {
connectionUri += "?randomize=false&backup=true&backupPoolSize=" + backups;
}
Transport transport = TransportFactory.connect(new URI(connectionUri));
transport.setTransportListener(new TransportListener() {
@Override
public void onCommand(Object command) {
LOG.debug("Test Transport Listener received Command: " + command);
}
@Override
public void onException(IOException error) {
LOG.debug("Test Transport Listener received Exception: " + error);
}
@Override
public void transportInterupted() {
transportInterruptions++;
LOG.debug("Test Transport Listener records transport Interrupted: " + transportInterruptions);
}
@Override
public void transportResumed() {
transportResumptions++;
LOG.debug("Test Transport Listener records transport Resumed: " + transportResumptions);
}
});
transport.start();
this.failoverTransport = transport.narrow(FailoverTransport.class);
return transport;
}
use of org.apache.activemq.transport.Transport in project activemq-artemis by apache.
the class ProxyTestSupport method createConnection.
@Override
protected StubConnection createConnection() throws Exception {
Transport transport = TransportFactory.connect(connector.getServer().getConnectURI());
StubConnection connection = new StubConnection(transport);
connections.add(connection);
return connection;
}
use of org.apache.activemq.transport.Transport in project activemq-artemis by apache.
the class ProxyTestSupport method createProxyConnection.
protected StubConnection createProxyConnection() throws Exception {
Transport transport = TransportFactory.connect(proxyConnector.getServer().getConnectURI());
StubConnection connection = new StubConnection(transport);
connections.add(connection);
return connection;
}
use of org.apache.activemq.transport.Transport in project pinpoint by naver.
the class ActiveMQMessageConsumerDispatchInterceptor method recordRootSpan.
private void recordRootSpan(SpanRecorder recorder, Object target, Object[] args) {
recorder.recordServiceType(ActiveMQClientConstants.ACTIVEMQ_CLIENT);
recorder.recordApi(CONSUMER_ENTRY_METHOD_DESCRIPTOR);
ActiveMQSession session = ((ActiveMQSessionGetter) target)._$PINPOINT$_getActiveMQSession();
ActiveMQConnection connection = session.getConnection();
Transport transport = getRootTransport(((TransportGetter) connection)._$PINPOINT$_getTransport());
final String endPoint = getEndPoint(transport);
// Endpoint should be the local socket address of the consumer.
recorder.recordEndPoint(endPoint);
final String remoteAddress = transport.getRemoteAddress();
// Remote address is the socket address of where the consumer is connected to.
recorder.recordRemoteAddress(remoteAddress);
MessageDispatch md = (MessageDispatch) args[0];
ActiveMQMessage message = (ActiveMQMessage) md.getMessage();
ActiveMQDestination destination = message.getDestination();
// Rpc name is the URI of the queue/topic we're consuming from.
recorder.recordRpcName(destination.getQualifiedName());
// Record acceptor host as the queue/topic name in order to generate virtual queue node.
recorder.recordAcceptorHost(destination.getPhysicalName());
String parentApplicationName = ActiveMQClientHeader.getParentApplicationName(message, null);
if (!recorder.isRoot() && parentApplicationName != null) {
short parentApplicationType = ActiveMQClientHeader.getParentApplicationType(message, ServiceType.UNDEFINED.getCode());
recorder.recordParentApplication(parentApplicationName, parentApplicationType);
}
}
Aggregations