Search in sources :

Example 26 with Transport

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();
}
Also used : TransportListener(org.apache.activemq.transport.TransportListener) WireFormatInfo(org.apache.activemq.command.WireFormatInfo) IOException(java.io.IOException) Transport(org.apache.activemq.transport.Transport) URI(java.net.URI) TransportAcceptListener(org.apache.activemq.transport.TransportAcceptListener) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 27 with Transport

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;
}
Also used : TransportListener(org.apache.activemq.transport.TransportListener) IOException(java.io.IOException) Transport(org.apache.activemq.transport.Transport) URI(java.net.URI)

Example 28 with 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;
}
Also used : StubConnection(org.apache.activemq.broker.StubConnection) Transport(org.apache.activemq.transport.Transport)

Example 29 with Transport

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;
}
Also used : StubConnection(org.apache.activemq.broker.StubConnection) Transport(org.apache.activemq.transport.Transport)

Example 30 with Transport

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);
    }
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch) ActiveMQSessionGetter(com.navercorp.pinpoint.plugin.activemq.client.field.getter.ActiveMQSessionGetter) ActiveMQSession(org.apache.activemq.ActiveMQSession) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) Transport(org.apache.activemq.transport.Transport) FailoverTransport(org.apache.activemq.transport.failover.FailoverTransport) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Aggregations

Transport (org.apache.activemq.transport.Transport)31 StubConnection (org.apache.activemq.broker.StubConnection)16 URI (java.net.URI)12 IOException (java.io.IOException)5 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)5 TransportListener (org.apache.activemq.transport.TransportListener)5 FailoverTransport (org.apache.activemq.transport.failover.FailoverTransport)5 ActiveMQSessionGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.ActiveMQSessionGetter)3 SocketGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter)3 URISyntaxException (java.net.URISyntaxException)3 ActiveMQSession (org.apache.activemq.ActiveMQSession)3 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)3 TransportAcceptListener (org.apache.activemq.transport.TransportAcceptListener)3 MockTransport (org.apache.activemq.transport.mock.MockTransport)3 TransportGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.TransportGetter)2 Socket (java.net.Socket)2 JMSException (javax.jms.JMSException)2 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)2 MessageDispatch (org.apache.activemq.command.MessageDispatch)2 File (java.io.File)1