Search in sources :

Example 6 with ActiveMQConnection

use of org.apache.activemq.ActiveMQConnection in project camel by apache.

the class ConnectionFactoryResourceTest method testDestroyObject.

@Test
public void testDestroyObject() throws Exception {
    ConnectionFactoryResource pool = new ConnectionFactoryResource(1, connectionFactory);
    pool.fillPool();
    assertNotNull(pool);
    ActiveMQConnection connection = (ActiveMQConnection) pool.makeObject();
    assertNotNull(connection);
    assertTrue(connection.isStarted());
    pool.drainPool();
    assertTrue(pool.size() == 0);
}
Also used : ActiveMQConnection(org.apache.activemq.ActiveMQConnection) Test(org.junit.Test)

Example 7 with ActiveMQConnection

use of org.apache.activemq.ActiveMQConnection in project camel by apache.

the class ConnectionFactoryResourceTest method testCreateObject.

@Test
public void testCreateObject() throws Exception {
    ConnectionFactoryResource pool = new ConnectionFactoryResource(1, connectionFactory);
    pool.fillPool();
    assertNotNull(pool);
    ActiveMQConnection connection = (ActiveMQConnection) pool.makeObject();
    assertNotNull(connection);
    assertTrue(connection.isStarted());
    pool.drainPool();
}
Also used : ActiveMQConnection(org.apache.activemq.ActiveMQConnection) Test(org.junit.Test)

Example 8 with ActiveMQConnection

use of org.apache.activemq.ActiveMQConnection in project camel by apache.

the class ConnectionFactoryResourceTest method testRoundRobbin.

@Test
public void testRoundRobbin() throws Exception {
    ConnectionFactoryResource pool = new ConnectionFactoryResource(2, connectionFactory);
    pool.fillPool();
    assertNotNull(pool);
    ActiveMQConnection connection = (ActiveMQConnection) pool.borrowConnection();
    assertNotNull(connection);
    assertTrue(connection.isStarted());
    pool.returnConnection(connection);
    ActiveMQConnection connection2 = (ActiveMQConnection) pool.borrowConnection();
    assertNotNull(connection2);
    assertNotEquals(connection, connection2);
    pool.drainPool();
}
Also used : ActiveMQConnection(org.apache.activemq.ActiveMQConnection) Test(org.junit.Test)

Example 9 with ActiveMQConnection

use of org.apache.activemq.ActiveMQConnection in project camel by apache.

the class ConnectionFactoryResourceTest method testReturnObject.

@Test
public void testReturnObject() throws Exception {
    ConnectionFactoryResource pool = new ConnectionFactoryResource(1, connectionFactory);
    pool.fillPool();
    assertNotNull(pool);
    ActiveMQConnection connection = (ActiveMQConnection) pool.borrowConnection();
    assertNotNull(connection);
    assertTrue(connection.isStarted());
    pool.returnConnection(connection);
    ActiveMQConnection connection2 = (ActiveMQConnection) pool.borrowConnection();
    assertNotNull(connection2);
    pool.drainPool();
}
Also used : ActiveMQConnection(org.apache.activemq.ActiveMQConnection) Test(org.junit.Test)

Example 10 with ActiveMQConnection

use of org.apache.activemq.ActiveMQConnection 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)

Aggregations

ActiveMQConnection (org.apache.activemq.ActiveMQConnection)12 Test (org.junit.Test)5 SocketGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter)4 Transport (org.apache.activemq.transport.Transport)4 ActiveMQSessionGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.ActiveMQSessionGetter)2 TransportGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.TransportGetter)2 Socket (java.net.Socket)2 SocketAddress (java.net.SocketAddress)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)2 ActiveMQSession (org.apache.activemq.ActiveMQSession)2 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Connection (javax.jms.Connection)1 NamingException (javax.naming.NamingException)1 RedeliveryPolicy (org.apache.activemq.RedeliveryPolicy)1 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)1