private void receiveMessage ( ) { MessagingSystemInfo messagingSystemInfo = oneAgentSdk . createMessagingSystemInfo ( "DynatraceSample" , "theQueue" , MessageDestinationType . QUEUE , ChannelType . IN_PROCESS , null ) ; IncomingMessageReceiveTracer incomingMessageReceiveTracer = oneAgentSdk . traceIncomingMessageReceive ( messagingSystemInfo ) ; incomingMessageReceiveTracer . start ( ) ; try { Message msg = queueManager . receive ( "theQeue" ) ; if ( msg == null ) { return ; // no message received } IncomingMessageProcessTracer incomingMessageProcessTracer = oneAgentSdk . traceIncomingMessageProcess ( messagingSystemInfo ) ; // store incoming tag to tracer: incomingMessageProcessTracer . setDynatraceStringTag ( msg . getProperty ( OneAgentSDK . DYNATRACE_MESSAGE_PROPERTYNAME ) ) ; incomingMessageProcessTracer . setVendorMessageId ( msg . getVendorMessageId ( ) ) ; incomingMessageProcessTracer . start ( ) ; try { // do something with the message ... System . out . println ( "Message received: " + msg . toString ( ) ) ; } catch ( Exception e ) { incomingMessageProcessTracer . error ( e ) ; } finally { incomingMessageProcessTracer . end ( ) ; } } catch ( Exception e ) { incomingMessageReceiveTracer . error ( e ) ; } finally { incomingMessageReceiveTracer . end ( ) ; } }
shows how to trace a blocking receive of a message