Use a different queue per test
MODIFY
dd-java-agent/instrumentation/jms/src/latestDepTest/groovy/SpringListenerJMS2Test.groovy
dd-java-agent/instrumentation/jms/src/latestDepTest/groovy/SpringListenerJMS2Test.groovy
@@ -34,7 +34,7 @@ class SpringListenerJMS2Test extends AgentTestRunner {
def context = new AnnotationConfigApplicationContext(Config)
def factory = context.getBean(ConnectionFactory)
def template = new JmsTemplate(factory)
- template.convertAndSend("someSpringQueue", "a message")
+ template.convertAndSend("SpringListenerJMS2", "a message")
TEST_WRITER.waitForTraces(3)
// Manually reorder if reported in the wrong order.
@@ -46,9 +46,9 @@ class SpringListenerJMS2Test extends AgentTestRunner {
expect:
assertTraces(3) {
- producerTrace(it, 0, "Queue someSpringQueue")
- consumerTrace(it, 1, "Queue someSpringQueue", false, HornetQMessageConsumer)
- consumerTrace(it, 2, "Queue someSpringQueue", true, MessagingMessageListenerAdapter)
+ producerTrace(it, 0, "Queue SpringListenerJMS2")
+ consumerTrace(it, 1, "Queue SpringListenerJMS2", false, HornetQMessageConsumer)
+ consumerTrace(it, 2, "Queue SpringListenerJMS2", true, MessagingMessageListenerAdapter)
}
}
}

MODIFY
dd-java-agent/instrumentation/jms/src/latestDepTest/groovy/SpringTemplateJMS2Test.groovy
dd-java-agent/instrumentation/jms/src/latestDepTest/groovy/SpringTemplateJMS2Test.groovy
@@ -10,6 +10,7 @@ import org.hornetq.core.config.impl.ConfigurationImpl
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory
+import org.hornetq.core.server.HornetQServer
import org.hornetq.core.server.HornetQServers
import org.hornetq.jms.client.HornetQMessageConsumer
import org.springframework.jms.core.JmsTemplate
@@ -23,6 +24,8 @@ import static JMS2Test.consumerTrace
import static JMS2Test.producerTrace
class SpringTemplateJMS2Test extends AgentTestRunner {
+ @Shared
+ HornetQServer server
@Shared
String messageText = "a message"
@Shared
@@ -45,12 +48,13 @@ class SpringTemplateJMS2Test extends AgentTestRunner {
config.setAcceptorConfigurations([new TransportConfiguration(NettyAcceptorFactory.name),
new TransportConfiguration(InVMAcceptorFactory.name)].toSet())
- HornetQServers.newHornetQServer(config).start()
+ server = HornetQServers.newHornetQServer(config)
+ server.start()
def serverLocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.name))
def sf = serverLocator.createSessionFactory()
def clientSession = sf.createSession(false, false, false)
- clientSession.createQueue("jms.queue.someSpringQueue", "jms.queue.someSpringQueue", true)
+ clientSession.createQueue("jms.queue.SpringTemplateJMS2", "jms.queue.SpringTemplateJMS2", true)
clientSession.close()
sf.close()
serverLocator.close()
@@ -67,6 +71,10 @@ class SpringTemplateJMS2Test extends AgentTestRunner {
template.receiveTimeout = TimeUnit.SECONDS.toMillis(10)
}
+ def cleanupSpec() {
+ server.stop()
+ }
+
def "sending a message to #jmsResourceName generates spans"() {
setup:
template.convertAndSend(destination, messageText)
@@ -81,7 +89,7 @@ class SpringTemplateJMS2Test extends AgentTestRunner {
where:
destination | jmsResourceName
- session.createQueue("someSpringQueue") | "Queue someSpringQueue"
+ session.createQueue("SpringTemplateJMS2") | "Queue SpringTemplateJMS2"
}
def "send and receive message generates spans"() {
@@ -119,6 +127,6 @@ class SpringTemplateJMS2Test extends AgentTestRunner {
where:
destination | jmsResourceName
- session.createQueue("someSpringQueue") | "Queue someSpringQueue"
+ session.createQueue("SpringTemplateJMS2") | "Queue SpringTemplateJMS2"
}
}

MODIFY
dd-java-agent/instrumentation/jms/src/latestDepTest/groovy/listener/Config.groovy
dd-java-agent/instrumentation/jms/src/latestDepTest/groovy/listener/Config.groovy
@@ -25,6 +25,7 @@ import org.hornetq.core.config.impl.ConfigurationImpl
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory
+import org.hornetq.core.server.HornetQServer
import org.hornetq.core.server.HornetQServers
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
@@ -33,6 +34,7 @@ import org.springframework.jms.annotation.EnableJms
import org.springframework.jms.config.DefaultJmsListenerContainerFactory
import org.springframework.jms.config.JmsListenerContainerFactory
+import javax.annotation.PreDestroy
import javax.jms.ConnectionFactory
@Configuration
@@ -40,6 +42,8 @@ import javax.jms.ConnectionFactory
@EnableJms
class Config {
+ private HornetQServer server
+
@Bean
ConnectionFactory connectionFactory() {
def tempDir = Files.createTempDir()
@@ -56,12 +60,13 @@ class Config {
config.setAcceptorConfigurations([new TransportConfiguration(NettyAcceptorFactory.name),
new TransportConfiguration(InVMAcceptorFactory.name)].toSet())
- HornetQServers.newHornetQServer(config).start()
+ server = HornetQServers.newHornetQServer(config)
+ server.start()
def serverLocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.name))
def sf = serverLocator.createSessionFactory()
def clientSession = sf.createSession(false, false, false)
- clientSession.createQueue("jms.queue.someSpringQueue", "jms.queue.someSpringQueue", true)
+ clientSession.createQueue("jms.queue.SpringListenerJMS2", "jms.queue.SpringListenerJMS2", true)
clientSession.close()
sf.close()
serverLocator.close()
@@ -76,4 +81,9 @@ class Config {
factory.setConnectionFactory(connectionFactory)
return factory
}
+
+ @PreDestroy
+ void destroy() {
+ server.stop()
+ }
}

MODIFY
dd-java-agent/instrumentation/jms/src/latestDepTest/groovy/listener/TestListener.groovy
dd-java-agent/instrumentation/jms/src/latestDepTest/groovy/listener/TestListener.groovy
@@ -21,7 +21,7 @@ import org.springframework.stereotype.Component
@Component
class TestListener {
- @JmsListener(destination = "someSpringQueue", containerFactory = "containerFactory")
+ @JmsListener(destination = "SpringListenerJMS2", containerFactory = "containerFactory")
void receiveMessage(String message) {
println "received: " + message
}

Use a different queue per test