Search in sources :

Example 31 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch in project activemq-artemis by apache.

the class MessageDispatchTest method createObject.

@Override
public Object createObject() throws Exception {
    MessageDispatch info = new MessageDispatch();
    populateObject(info);
    return info;
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Example 32 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch in project pinpoint by naver.

the class ActiveMQMessageConsumerDispatchInterceptor method validate.

private boolean validate(Object target, Object[] args) {
    if (!(target instanceof ActiveMQMessageConsumer)) {
        return false;
    }
    if (!(target instanceof ActiveMQSessionGetter)) {
        if (isDebug) {
            logger.debug("Invalid target object. Need field accessor({}).", ActiveMQSessionGetter.class.getName());
        }
        return false;
    }
    if (!validateTransport(((ActiveMQSessionGetter) target)._$PINPOINT$_getActiveMQSession())) {
        return false;
    }
    if (ArrayUtils.isEmpty(args)) {
        return false;
    }
    if (!(args[0] instanceof MessageDispatch)) {
        return false;
    }
    MessageDispatch md = (MessageDispatch) args[0];
    Message message = md.getMessage();
    if (!(message instanceof ActiveMQMessage)) {
        return false;
    }
    return true;
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch) ActiveMQSessionGetter(com.navercorp.pinpoint.plugin.activemq.client.field.getter.ActiveMQSessionGetter) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) Message(org.apache.activemq.command.Message) ActiveMQMessageConsumer(org.apache.activemq.ActiveMQMessageConsumer) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage)

Example 33 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch in project pinpoint by naver.

the class ActiveMQMessageConsumerDispatchInterceptor method createTrace.

private Trace createTrace(Object target, Object[] args) {
    if (!validate(target, args)) {
        return null;
    }
    MessageDispatch md = ArrayArgumentUtils.getArgument(args, 0, MessageDispatch.class);
    ActiveMQMessage message = (ActiveMQMessage) md.getMessage();
    if (filterDestination(message.getDestination())) {
        return null;
    }
    // These might trigger unmarshalling.
    if (!ActiveMQClientHeader.getSampled(message, true)) {
        return traceContext.disableSampling();
    }
    final TraceId traceId = populateTraceIdFromRequest(message);
    final Trace trace = traceId == null ? traceContext.newTraceObject() : traceContext.continueTraceObject(traceId);
    if (trace.canSampled()) {
        SpanRecorder recorder = trace.getSpanRecorder();
        recordRootSpan(recorder, target, args);
    }
    return trace;
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage)

Example 34 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch 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

MessageDispatch (org.apache.activemq.command.MessageDispatch)34 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)6 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)4 ActiveMQSessionGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.ActiveMQSessionGetter)3 Transport (org.apache.activemq.transport.Transport)3 IOException (java.io.IOException)2 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)2 ActiveMQSession (org.apache.activemq.ActiveMQSession)2 BrokerService (org.apache.activemq.broker.BrokerService)2 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)2 SocketGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter)1 Socket (java.net.Socket)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Destination (javax.jms.Destination)1 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)1 Broker (org.apache.activemq.broker.Broker)1 BrokerFilter (org.apache.activemq.broker.BrokerFilter)1 BrokerPlugin (org.apache.activemq.broker.BrokerPlugin)1