# APM Spring JMS Template

**URL:** <https://discuss.elastic.co/t/apm-spring-jms-template/201796>\
**Category:** APM\
**Tags:** java\
**Created:** [October 1, 2019, 12:49pm UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796 "2019-10-01T12:49:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [October 1, 2019, 12:49pm UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/1 "2019-10-01T12:49:49Z")

</div>

When I follow the standard way of Spring to use JMSTeplate, the the APM agent trace the JMS trace as shown below.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/e/1e7fa8c1a361e1956c70965bc632a1cd967d4792.png)

Are there some limitations of usage from Spring-JmsTemplate ?

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [October 1, 2019, 2:59pm UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/2 "2019-10-01T14:59:06Z")

</div>

Hi and thanks for your question. What would you like to see instead?

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [October 2, 2019, 6:25am UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/3 "2019-10-02T06:25:04Z")

</div>

The name of the destination 😃.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 2, 2019, 7:05am UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/4 "2019-10-02T07:05:04Z")

</div>

Right, this is one of the things we are going to add next.

First, we want to properly add them to our schema, which is [WIP](https://github.com/elastic/apm/issues/143). The current plan is to add the destination **name** (not address) as `context.message.queue.name` and `context.message.topic.name`. Is that what you are looking for?

A few quick questions:

- Why isn't distributed tracing working in this case? Do you have an agent on the sender as well?
- What does your app do when receiving a message like in this screenshot? Does it do additional actions you would expect to see spans for (eg DB query, remote HTTP request, manually created custom spans)?

Thanks,  
Eyal.

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [October 2, 2019, 8:19am UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/5 "2019-10-02T08:19:14Z")

</div>

H Eyal,

so I evaluate the problem.

There are Serval things:

1. If I use the jms from my app code then everything works excpected
2. If I send messages over the admin cosnsole from artemis jms broker then the spans doent covered. But I can life with that behviour.
3. I have two Spring application. In the first app jms used over JMS 2.0 api. The second spring app uses jms over Spring JmsTemplate. And this one have always the span wit "JMS RECEIVE" without a desination name.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 2, 2019, 9:48am UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/6 "2019-10-02T09:48:36Z")

</div>

Ahh right, it's missing in the span name...  
If you don't see any agent-related errors or warnings, I would guess this is related to the receive method returning without a valid message.

Please try to make sure you are looking at a receive method that returned a message object, or look for interesting things in logs.

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [October 2, 2019, 11:19am UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/7 "2019-10-02T11:19:27Z")

</div>

```
2019-10-02 13:15:09.305 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Type match for instrumentation ReceiveInstrumentation: (not(isInterface()) and hasSuperType(erasure(name(equals(javax.jms.MessageConsumer))))) matches class org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer
2019-10-02 13:15:09.305 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Type match for instrumentation SetMessageListenerInstrumentation: (not(isInterface()) and hasSuperType(erasure(name(equals(javax.jms.MessageConsumer))))) matches class org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer
2019-10-02 13:15:09.315 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Method match for instrumentation SetMessageListenerInstrumentation: (name(equals(setMessageListener)) and hasParameter(hasTypes(with(0 matches erasure(name(equals(javax.jms.MessageListener))))))) matches public void org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer.setMessageListener(javax.jms.MessageListener) throws javax.jms.JMSException
2019-10-02 13:15:09.315 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Method match for instrumentation ReceiveInstrumentation: (((name(equals(receive)) and (hasParameter(ofSize(0)) or hasParameter(ofSize(1)))) and isPublic()) or (name(equals(receiveNoWait)) and (hasParameter(ofSize(0)) and isPublic()))) matches public javax.jms.Message org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer.receive() throws javax.jms.JMSException
2019-10-02 13:15:09.316 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Method match for instrumentation ReceiveInstrumentation: (((name(equals(receive)) and (hasParameter(ofSize(0)) or hasParameter(ofSize(1)))) and isPublic()) or (name(equals(receiveNoWait)) and (hasParameter(ofSize(0)) and isPublic()))) matches public javax.jms.Message org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer.receive(long) throws javax.jms.JMSException
2019-10-02 13:15:09.316 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Method match for instrumentation ReceiveInstrumentation: (((name(equals(receive)) and (hasParameter(ofSize(0)) or hasParameter(ofSize(1)))) and isPublic()) or (name(equals(receiveNoWait)) and (hasParameter(ofSize(0)) and isPublic()))) matches public javax.jms.Message org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer.receiveNoWait() throws javax.jms.JMSException
2019-10-02 13:15:09.318 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.impl.transaction.AbstractSpan - increment references to '' 00-c81d42c68a873922b1f41a76dc0dbb56-753e620da4583a8b-01 (36f4b255) (1)
2019-10-02 13:15:09.318 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.impl.ElasticApmTracer - startTransaction '' 00-c81d42c68a873922b1f41a76dc0dbb56-753e620da4583a8b-01 (36f4b255) {
2019-10-02 13:15:09.318 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.impl.transaction.AbstractSpan - increment references to 'JMS RECEIVE' 00-c81d42c68a873922b1f41a76dc0dbb56-753e620da4583a8b-01 (36f4b255) (2)
2019-10-02 13:15:09.318 [DefaultMessageListenerContainer-1] DEBUG co.elastic.apm.agent.impl.ElasticApmTracer - Activating 'JMS RECEIVE' 00-c81d42c68a873922b1f41a76dc0dbb56-753e620da4583a8b-01 (36f4b255) on thread 120
```

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 2, 2019, 11:47am UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/8 "2019-10-02T11:47:54Z")

</div>

All JMS receive transactions start with the name `JMS RECEIVE`. The destination is appended to the name if the `receive` method is returning a (non-null) `Message`.

In upcoming releases this will be changed, so that JMS receive actions retuning `null` will be discarded.

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [October 7, 2019, 8:20am UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/9 "2019-10-07T08:20:14Z")

</div>

Thanks for clarification

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 28, 2019, 4:20am UTC](https://discuss.elastic.co/t/apm-spring-jms-template/201796/10 "2019-10-28T04:20:16Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
