JFR JmsTemplate
An implementation of Spring JmsTemplate that generates Flight Recorder events.
Versions 2.x are for Jakarta EE 9+ / Spring 6, versions 1.x are for Jakarta EE 8 / Spring 5.
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>jfr-jmstemplate</artifactId>
<version>2.0.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 jakarta.jms.Queue#getQueueName()
and jakarta.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.