JFR JmsTemplate
An implementation of Spring JmsTemplate that generates Flight Recorder events.
This project requires Java 11 based on OpenJDK or later.
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>jfr-jmstemplate</artifactId>
<version>0.1.0</version>
</dependency>
Compared to approaches based on ConnectionFactory
an approach based on JmsTemplate
has the advantage that it captures a complete queue interaction. A JmsTemplate
based approach generates a single JFR event for an entire message queue interaction that involves several JMS method invocations.
Overhead
We try to keep overhead to a minimum and have no additional allocations besides the JFR events. Besides the overhead of the event the only additional overhead is
- a wrapper around
JmsTemplate
- a few
instanceof
operations and casts - a
finally
block
We assume javax.jms.Queue#getQueueName()
and javax.jms.Topic#getTopicName()
are simple getters.
Usage
@Configuration
public class JmsConfiguration {
@Autowired
private ConnectionFactory connectionFactory;
@Bean
public JmsOperations jmsOperations() {
return new JfrJmsOperations(new JmsTemplate(this.connectionFactory));
}
}
Limitations
- We can not intercept
JmsTemplate#setDefaultDestination(Destination)
orJmsTemplate#setDefaultDestinationName(String)
so for operations on the default destination we can not report the destination name.