Search in sources :

Example 11 with Transport

use of org.apache.activemq.transport.Transport 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();
}
Also used : Transport(org.apache.activemq.transport.Transport) URI(java.net.URI) TransportAcceptListener(org.apache.activemq.transport.TransportAcceptListener) Socket(java.net.Socket)

Example 12 with Transport

use of org.apache.activemq.transport.Transport in project pinpoint by naver.

the class ActiveMQMessageConsumerDispatchInterceptor method validateTransport.

private boolean validateTransport(ActiveMQSession session) {
    if (session == null) {
        return false;
    }
    ActiveMQConnection connection = session.getConnection();
    if (!(connection instanceof TransportGetter)) {
        if (isDebug) {
            logger.debug("Invalid connection object. Need field accessor({}).", TransportGetter.class.getName());
        }
        return false;
    }
    Transport transport = getRootTransport(((TransportGetter) connection)._$PINPOINT$_getTransport());
    if (!(transport instanceof SocketGetter)) {
        if (isDebug) {
            logger.debug("Transport not traceable({}).", transport.getClass().getName());
        }
        return false;
    }
    return true;
}
Also used : SocketGetter(com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) TransportGetter(com.navercorp.pinpoint.plugin.activemq.client.field.getter.TransportGetter) Transport(org.apache.activemq.transport.Transport) FailoverTransport(org.apache.activemq.transport.failover.FailoverTransport)

Example 13 with Transport

use of org.apache.activemq.transport.Transport in project pinpoint by naver.

the class ActiveMQMessageProducerSendInterceptor method validateTransport.

private boolean validateTransport(ActiveMQSession session) {
    if (session == null) {
        return false;
    }
    ActiveMQConnection connection = session.getConnection();
    if (!(connection instanceof TransportGetter)) {
        if (isDebug) {
            logger.debug("Invalid connection object. Need field accessor({}).", TransportGetter.class.getName());
        }
        return false;
    }
    Transport transport = getRootTransport(((TransportGetter) connection)._$PINPOINT$_getTransport());
    if (!(transport instanceof SocketGetter)) {
        if (isDebug) {
            logger.debug("Transport not traceable({}).", transport.getClass().getName());
        }
        return false;
    }
    return true;
}
Also used : SocketGetter(com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) TransportGetter(com.navercorp.pinpoint.plugin.activemq.client.field.getter.TransportGetter) Transport(org.apache.activemq.transport.Transport) FailoverTransport(org.apache.activemq.transport.failover.FailoverTransport)

Example 14 with Transport

use of org.apache.activemq.transport.Transport in project pinpoint by naver.

the class ActiveMQMessageConsumerDispatchInterceptor method doInBeforeTrace.

@Override
protected void doInBeforeTrace(SpanRecorder recorder, Object target, Object[] args) {
    recorder.recordServiceType(ActiveMQClientConstants.ACTIVEMQ_CLIENT);
    ActiveMQSession session = ((ActiveMQSessionGetter) target)._$PINPOINT$_getActiveMQSession();
    ActiveMQConnection connection = session.getConnection();
    Transport transport = getRootTransport(((TransportGetter) connection)._$PINPOINT$_getTransport());
    Socket socket = ((SocketGetter) transport)._$PINPOINT$_getSocket();
    SocketAddress localSocketAddress = socket.getLocalSocketAddress();
    String endPoint = ActiveMQClientUtils.getEndPoint(localSocketAddress);
    // Endpoint should be the local socket address of the consumer.
    recorder.recordEndPoint(endPoint);
    SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
    String remoteAddress = ActiveMQClientUtils.getEndPoint(remoteSocketAddress);
    // 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) SocketGetter(com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) Transport(org.apache.activemq.transport.Transport) SocketAddress(java.net.SocketAddress) Socket(java.net.Socket) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 15 with Transport

use of org.apache.activemq.transport.Transport in project activemq-artemis by apache.

the class ActiveMQConnectionFactory method createTransport.

protected Transport createTransport() throws JMSException {
    try {
        System.out.println("xxxxxcreating conn: " + brokerURL.toString());
        Transport t = TransportFactory.connect(brokerURL);
        System.out.println("xxxxxxxxxxxx created transport" + t);
        return t;
    } catch (Exception e) {
        throw JMSExceptionSupport.create("Could not create Transport. Reason: " + e, e);
    }
}
Also used : Transport(org.apache.activemq.transport.Transport) URISyntaxException(java.net.URISyntaxException) JMSException(javax.jms.JMSException)

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