Search in sources :

Example 11 with MessageDispatch

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

the class MessageDispatchTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    MessageDispatch info = (MessageDispatch) object;
    info.setConsumerId(createConsumerId("ConsumerId:1"));
    info.setDestination(createActiveMQDestination("Destination:2"));
    info.setMessage(createMessage("Message:3"));
    info.setRedeliveryCounter(1);
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Example 12 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 13 with MessageDispatch

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

the class MessageDispatchTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    MessageDispatch info = (MessageDispatch) object;
    info.setConsumerId(createConsumerId("ConsumerId:1"));
    info.setDestination(createActiveMQDestination("Destination:2"));
    info.setMessage(createMessage("Message:3"));
    info.setRedeliveryCounter(1);
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Example 14 with MessageDispatch

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

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

the class BrokerNetworkWithStuckMessagesTest method receiveMessage.

public Message receiveMessage(StubConnection connection, long timeout) throws InterruptedException {
    while (true) {
        Object o = connection.getDispatchQueue().poll(timeout, TimeUnit.MILLISECONDS);
        if (o == null) {
            return null;
        }
        if (o instanceof MessageDispatch) {
            MessageDispatch dispatch = (MessageDispatch) o;
            if (dispatch.getMessage() == null) {
                return null;
            }
            dispatch.setMessage(dispatch.getMessage().copy());
            dispatch.getMessage().setRedeliveryCounter(dispatch.getRedeliveryCounter());
            return dispatch.getMessage();
        }
    }
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

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