Search in sources :

Example 6 with ActiveMQSession

use of org.apache.activemq.ActiveMQSession in project pinpoint by naver.

the class ActiveMQMessageProducerSendInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args);
    }
    if (!validate(target, args)) {
        return;
    }
    Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(descriptor);
        if (throwable == null) {
            ActiveMQDestination destination = (ActiveMQDestination) args[0];
            // This annotation indicates the uri to which the call is made
            recorder.recordAttribute(AnnotationKey.MESSAGE_QUEUE_URI, destination.getQualifiedName());
            // DestinationId is used to render the virtual queue node.
            // We choose the queue/topic name as the logical name of the queue node.
            recorder.recordDestinationId(destination.getPhysicalName());
            ActiveMQSession session = ((ActiveMQSessionGetter) target)._$PINPOINT$_getActiveMQSession();
            ActiveMQConnection connection = session.getConnection();
            Transport transport = getRootTransport(((TransportGetter) connection)._$PINPOINT$_getTransport());
            Socket socket = ((SocketGetter) transport)._$PINPOINT$_getSocket();
            SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
            String remoteAddress = ActiveMQClientUtils.getEndPoint(remoteSocketAddress);
            // Producer's endPoint should be the socket address of where the producer is actually connected to.
            recorder.recordEndPoint(remoteAddress);
            recorder.recordAttribute(ActiveMQClientConstants.ACTIVEMQ_BROKER_URL, remoteAddress);
        } else {
            recorder.recordException(throwable);
        }
    } catch (Throwable t) {
        logger.warn("AFTER error. Cause:{}", t.getMessage(), t);
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) 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) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) Transport(org.apache.activemq.transport.Transport) SocketAddress(java.net.SocketAddress) Socket(java.net.Socket) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Aggregations

ActiveMQSession (org.apache.activemq.ActiveMQSession)6 MessageProducer (javax.jms.MessageProducer)4 TextMessage (javax.jms.TextMessage)4 Test (org.junit.Test)4 MessageConsumer (javax.jms.MessageConsumer)3 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)3 ActiveMQSessionGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.ActiveMQSessionGetter)2 SocketGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter)2 AssertTextMessageListener (com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.AssertTextMessageListener)2 MessageConsumerBuilder (com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.MessageConsumerBuilder)2 MessageProducerBuilder (com.navercorp.pinpoint.plugin.jdk7.activemq.client.util.MessageProducerBuilder)2 Socket (java.net.Socket)2 SocketAddress (java.net.SocketAddress)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Message (javax.jms.Message)2 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)2 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)2 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)2 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)2