In this article, we’ll use OpenTelemetry tracing to instrument a Spring JMS application with Oracle Database Free. Tracing allows developers to follow a request as it flows through distributed systems — in this case, from the producer to the consumer through Oracle Database Transactional Event Queues (TxEventQ).
Tracing helps correlate slow consumers, lost messages, or queue bottlenecks to specific spans.
Just looking for the code? Click Here.

Oracle Database and JMS
Oracle Database supports a wide variety of messaging paradigms out-of-the-box with Transactional Event Queues (TxEventQ), including JMS. While we focus on JMS in this article, you can also message with PL/SQL, Kafka APIs, and more.
To start using JMS, assign the following permissions to a database user:
-- Configure testuser with the necessary privileges to use Transactional Event Queues for JMS:
grant aq_user_role to testuser;
grant execute on dbms_aq to testuser;
grant execute on dbms_aqadm to testuser;
grant execute ON dbms_aqin TO testuser;
grant execute ON dbms_aqjms TO testuser;Then, you can create and start JMS queues in the database:
-- Create a Transactional Event Queue
begin
-- See https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_AQADM.html#GUID-93B0FF90-5045-4437-A9C4-B7541BEBE573
-- For documentation on creating Transactional Event Queues.
dbms_aqadm.create_transactional_event_queue(
queue_name => 'testuser.testqueue',
-- Payload can be RAW, JSON, DBMS_AQADM.JMS_TYPE, or an object type.
-- Default is DBMS_AQADM.JMS_TYPE.
queue_payload_type => DBMS_AQADM.JMS_TYPE,
-- FALSE means queues can only have one consumer for each message. This is the default.
-- TRUE means queues created in the table can have multiple consumers for each message.
multiple_consumers => false
);
-- Start the queue
dbms_aqadm.start_queue(
queue_name => 'testuser.testqueue'
);
end;
/You can find the sample SQL script in the grant_permissions.sql file.
Dependencies
Oracle Database TxEventQ uses normal database connections for messaging – so, we’ll pull in the spring-boot-starter-data-jdbc dependency to configure a Java DataSource.
We also use the oracle-spring-boot-starter-aqjms dependency to pull in all the required JMS dependencies for Oracle:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.spring</groupId>
<artifactId>oracle-spring-boot-starter-aqjms</artifactId>
<version>${oracle.starters.version}</version>
</dependency>
To enable tracing, we pull in the recommended Spring Boot and micrometer dependencies. Notice that we use Grafana LGTM to export traces, though this example should work with any trace exporter.
<!-- Observability / Tracing is implemented in Actuator. -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-opentelemetry</artifactId>
</dependency>
Spring property configuration
Our Spring properties contain both tracing and database connection information. Because this is a demo app, we sample 100% of the traces – it’s generally recommended to sample 10% or fewer in a production app.
Notice there’s no JMS configuration, only a Spring DataSource. This is because Oracle’s JMS implementation uses that DataSource for JMS!
# Tracing Configuration
management:
opentelemetry:
tracing:
export:
otlp:
endpoint: http://localhost:4318/v1/traces
tracing:
export:
otlp:
enabled: true
sampling:
# Send 100% of spans
probability: 1
spring:
application:
name: JMSTracingApp
profiles:
active: scheduleProducer
datasource:
username: testuser
password: testpwd
# Docker compose Oracle Free container
url: jdbc:oracle:thin:@localhost:1522/freepdb1
# Set these to use UCP over Hikari.
driver-class-name: oracle.jdbc.OracleDriver
type: oracle.ucp.jdbc.PoolDataSource
oracleucp:
initial-pool-size: 1
min-pool-size: 1
max-pool-size: 30
connection-pool-name: UCPSampleApplication
connection-factory-class-name: oracle.jdbc.pool.OracleDataSourceJMS Producer and Consumer
For our tracing sample, let’s implement a JMS producer and consumer using Spring JMS APIs. We’ll later see traces passing through these classes!
The ScheduledProducer publishes a message every second to a queue using Spring’s JMSTemplate:
package com.example.tracing.jms;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.Instant;
@Component
public class ScheduledProducer {
private final JmsTemplate producer;
private final String queueName;
public ScheduledProducer(JmsTemplate producer,
@Value("${txeventq.queue.name:testqueue}") String queueName) {
this.producer = producer;
this.queueName = queueName;
}
@Scheduled(fixedRate = 1000)
public void produce() {
this.producer.convertAndSend(queueName, "Message: " + Instant.now());
}
}The Consumer registers a JMSListener on that queue, and processes the messages:
package com.example.tracing.jms;
import java.util.concurrent.CountDownLatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
@Component
public class Consumer {
private static final Logger log = LoggerFactory.getLogger(Consumer.class);
@JmsListener(destination = "${txeventq.queue.name:testqueue}", id = "sampleConsumer")
public void receiveMessage(String message) {
log.info("Received Message: {}", message);
}
}Notice we write a log message in the receiveMessage method, automatically logging the trace ID (injected by Spring Boot!).
Try it out with Oracle Database Free
To test out JMS tracing, start up Grafana LGTM and Oracle Database Free containers using the docker-compose script:
docker-compose up -dThe script configures the database container with a test user and a JMS queue using the grant_permissions.sql script.
Next, start the Java app, which will automatically connect to the Grafana LGTM and database containers:
mvn spring-boot:runAs the app processes messages, you will see trace IDs logged from the JMS consumer:
2025-10-06T13:04:55.173-07:00 INFO 38731 --- [JMSTracingApp] [ampleConsumer-1] [826248b10168fdba96386521023a6475-0e2395ab2a35fe92] com.example.tracing.jms.Consumer : Received Message: Message: 2025-10-06T20:04:55.138588Z
Here, 826248b10168fdba96386521023a6475 is the trace ID generated by Spring Boot, and included in the JMS span.
Time to view traces!
To view traces from the sample app, log in to the Grafana UI, using the container URL http://localhost:3000/a/grafana-exploretraces-app
Next, click “Traces” to find all traces, or search for a specific trace ID.
From the trace view, you can see the producer scheduling, publishing the event, and consuming the event in all in one place!

Expand each element to view additional details:

With OpenTelemetry tracing, you gain full visibility into message lifecycles within Oracle Database’s Transactional Event Queues — making it easier to debug, optimize, and monitor your applications.

Leave a Reply