use of org.apache.activemq.ActiveMQConnection 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();
}
}
use of org.apache.activemq.ActiveMQConnection in project tomee by apache.
the class ActiveMQResourceAdapter method makeConnection.
@Override
public ActiveMQConnection makeConnection(final MessageActivationSpec activationSpec) throws JMSException {
if (TomEEMessageActivationSpec.class.isInstance(activationSpec)) {
final TomEEMessageActivationSpec s = TomEEMessageActivationSpec.class.cast(activationSpec);
if (s.getConnectionFactoryLookup() != null) {
try {
final Object lookup = SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext().lookup("openejb:Resource/" + s.getConnectionFactoryLookup());
if (!ActiveMQConnectionFactory.class.isInstance(lookup)) {
final org.apache.activemq.ra.ActiveMQConnectionFactory connectionFactory = org.apache.activemq.ra.ActiveMQConnectionFactory.class.cast(lookup);
Connection connection = connectionFactory.createConnection();
if (Proxy.isProxyClass(connection.getClass())) {
// not great, we should find a better want without bypassing ra layer
final InvocationHandler invocationHandler = Proxy.getInvocationHandler(connection);
if (AutoConnectionTracker.ConnectionInvocationHandler.class.isInstance(invocationHandler)) {
final Object handle = Reflections.get(invocationHandler, "handle");
if (TomEEManagedConnectionProxy.class.isInstance(handle)) {
final ActiveMQManagedConnection c = ActiveMQManagedConnection.class.cast(Reflections.get(handle, "connection"));
final ActiveMQConnection physicalConnection = ActiveMQConnection.class.cast(Reflections.get(c, "physicalConnection"));
final RedeliveryPolicy redeliveryPolicy = activationSpec.redeliveryPolicy();
if (redeliveryPolicy != null) {
physicalConnection.setRedeliveryPolicy(redeliveryPolicy);
}
return physicalConnection;
}
}
}
/*
final RedeliveryPolicy redeliveryPolicy = activationSpec.redeliveryPolicy();
if (redeliveryPolicy != null) {
physicalConnection.setRedeliveryPolicy(redeliveryPolicy);
}
*/
return null;
}
} catch (final ClassCastException cce) {
throw new java.lang.IllegalStateException(cce);
} catch (final NamingException e) {
throw new IllegalArgumentException(e);
}
}
}
return super.makeConnection(activationSpec);
}
Aggregations