You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To configure Spring JMS to use Oracle Database Transactional Event Queues, you'll need to ensure your Spring datasource configuration is setup for Oracle Database:
Additionally, you should define a JMS ConnectionFactory bean using the AQjmsFactory class. The presence of the ConnectionFactory bean ensures Spring JMS uses Oracle Database Transactional Event Queues as the JMS provider for message operations.
290
-
291
-
```java
292
-
@Bean
293
-
public ConnectionFactory aqJmsConnectionFactory(DataSource ds) throws JMSException {
294
-
return AQjmsFactory.getConnectionFactory(ds);
295
-
}
296
-
```
297
-
298
-
The following Spring JMS Producer class makes use of Spring’s JMSTemplate, which is available via autowiring. The JMSTemplate class provides a simple API for working with JMS — here we use the convertAndSend method to produce messages to a queue.
299
-
300
-
The JMSTemplate class provides a variety of JMS functionality, and may also be used to receive messages.
The following Spring JMS Consumer class uses Spring’s @JmsListener annotation to set up a message receiver for a given queue — in this case, a queue named “testqueue”. The basic consumer prints each message it receives to stdout.
Copy file name to clipboardExpand all lines: docs-source/transactional-event-queues/content/kafka/_index.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,3 +46,7 @@ Oracle offers a Kafka connector for TxeventQ, enabling seamless integration of m
46
46
## Transactional Messaging
47
47
48
48
One of TxEventQ's unique features is its ability to combine messaging and database operations within a single transaction. This capability, often referred to as the "transactional outbox" pattern, ensures data consistency across microservices. We'll explore this pattern through the Kafka Java Client for Oracle Database Transactional Event Queues.
49
+
50
+
## Spring Boot Integration
51
+
52
+
Spring Boot integration is supported through the [Kafka Java Client for Oracle Database Transactional Event Queues' Spring Boot Starter](https://central.sonatype.com/artifact/com.oracle.database.spring/oracle-spring-boot-starter-okafka). You can read more about the starter in the [Spring Boot Kafka section](../spring-boot/kafka.md).
Copy file name to clipboardExpand all lines: docs-source/transactional-event-queues/content/kafka/kafka-connectors.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title = "Kafka Connectors"
4
4
weight = 3
5
5
+++
6
6
7
-
This section provides examples using Kafka connectors to connect Oracle Database Transactional Event Queues with other data and messaging systems, like [Apache Kafka](https://github.com/oracle/okafka/tree/master/connectors).
7
+
This section introduces Kafka connectors to connect Oracle Database Transactional Event Queues with other data and messaging systems, like [Apache Kafka](https://github.com/oracle/okafka/tree/master/connectors) topics.
Copy file name to clipboardExpand all lines: docs-source/transactional-event-queues/content/spring-boot/_index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The Oracle Spring Boot Starter for AQ/JMS simplifies TxEventQ integration with S
16
16
17
17
## Spring Boot Starter for Kafka Java Client for Oracle Database Transactional Event Queues
18
18
19
-
The Kafka Java Client for TxEventQ Spring Boot Starter pulls in all necessary dependencies to work with TxEventQ's[Kafka Java API](https://github.com/oracle/okafka) using Spring Boot.
19
+
The Kafka Java Client for Oracle Database Transactional Event Queues Spring Boot Starter pulls in all necessary dependencies to work with Transactional Event Queues[Kafka Java API](https://github.com/oracle/okafka) using Spring Boot.
Copy file name to clipboardExpand all lines: docs-source/transactional-event-queues/content/spring-boot/jms.md
+141Lines changed: 141 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,144 @@ archetype = "page"
3
3
title = "Spring JMS"
4
4
weight = 1
5
5
+++
6
+
7
+
Java Message Service (JMS) is an API that provides a standardized way for Java applications to create, send, receive, and read messages in messaging systems. [Spring JMS](https://spring.io/guides/gs/messaging-jms) uses idiomatic APIs to produce and consume messages with JMS, using the JMSTemplate class and @JMSListener annotations for producers and consumers, respectively.
8
+
9
+
In this section, we’ll implement a producer/consumer example using Spring JMS with Oracle Database Transactional Event Queues JMS APIs.
10
+
11
+
*[Project Dependencies](#project-dependencies)
12
+
*[Configure Permissions and Create a JMS Queue](#configure-permissions-and-create-a-jms-queue)
13
+
*[Connect Spring JMS to Oracle Database](#connect-spring-jms-to-oracle-database)
14
+
*[JMSTemplate Producer](#jmstemplate-producer)
15
+
*[Receive messages with @JMSListener](#receive-messages-with-jmslistener)
16
+
17
+
## Project Dependencies
18
+
19
+
To start developing with the Spring JMS for Oracle Database Transactional Event Queues, add the [oracle-spring-boot-starter-aqjms](https://central.sonatype.com/artifact/com.oracle.database.spring/oracle-spring-boot-starter-aqjms) dependency to your Maven project, along with Spring Boot JDBC:
The following SQL script grants the necessary permissions to use Transactional Event Queues with JMS to a database user, and then creates a Transactional Event Queue with a [JMS Payload Type](../getting-started/core-concepts.md#dbms_aqadmjms_type) for use by that user. We’ll dynamically invoke this script in our test later on, and it is provided here for reference purposes.
44
+
45
+
```sql
46
+
grant aq_user_role to testuser;
47
+
grant execute on dbms_aq to testuser;
48
+
grant execute on dbms_aqadm to testuser;
49
+
grant execute ON dbms_aqin TO testuser;
50
+
grant execute ON dbms_aqjms TO testuser;
51
+
grant execute on dbms_teqk to testuser;
52
+
53
+
begin
54
+
-- Create a JMS queue
55
+
dbms_aqadm.create_transactional_event_queue(
56
+
queue_name =>'testuser.testqueue',
57
+
queue_payload_type =>DBMS_AQADM.JMS_TYPE,
58
+
-- FALSE means queues can only have one consumer for each message. This is the default.
59
+
-- TRUE means queues created in the table can have multiple consumers for each message.
60
+
multiple_consumers => false
61
+
);
62
+
63
+
-- Start the queue
64
+
dbms_aqadm.start_queue(
65
+
queue_name =>'testuser.testqueue'
66
+
);
67
+
end;
68
+
/
69
+
```
70
+
71
+
## Connect Spring JMS to Oracle Database
72
+
73
+
Spring JMS with Oracle Database Transactional Event Queues uses a standard Oracle Database JDBC connection to produce and consume messages. To configure this with YAML-style Spring datasource properties, it'll look something like this (`src/main/resources/application.yaml`):
Additionally, you should define a JMS ConnectionFactory bean using the AQjmsFactory class. The presence of the ConnectionFactory bean ensures Spring JMS uses Oracle Database Transactional Event Queues as the JMS provider for message operations.
93
+
94
+
```java
95
+
@Bean
96
+
public ConnectionFactory aqJmsConnectionFactory(DataSource ds) throws JMSException {
97
+
return AQjmsFactory.getConnectionFactory(ds);
98
+
}
99
+
```
100
+
101
+
## JMSTemplate Producer
102
+
103
+
The Spring JMSTemplate bean provides an interface for JMS operations, including producing and consuming messages. The following class uses the `jmsTemplate.convertAndSend()` method to produce a message to a queue.
Copy file name to clipboardExpand all lines: docs-source/transactional-event-queues/content/spring-boot/kafka.md
+109Lines changed: 109 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,112 @@ archetype = "page"
3
3
title = "Kafka Starter"
4
4
weight = 2
5
5
+++
6
+
7
+
This section provides information on getting started using the Kafka Java Client for Oracle Database Transactional Event Queues from a Spring Boot application.
8
+
9
+
You can learn more about the Kafka APIs of Oracle Database Transactional Event Queues in the [Kafka chapter](../kafka/_index.md).
10
+
11
+
## Project Dependencies
12
+
13
+
[The Kafka Java Client for Oracle Database Transactional Event Queues Spring Boot Starter](https://central.sonatype.com/artifact/com.oracle.database.spring/oracle-spring-boot-starter-okafka) pulls in all necessary dependencies for developers to work with Transactional Event Queues' Kafka Java API using Spring Boot.
14
+
15
+
If you're using Maven, add the following dependency to your project:
We'll create a simple Spring Configuration class that pulls in properties for configuring the Kafka Java Client for Oracle Database Transactional Event Queues. You can read more about these configuration properties in the [Developing With Kafka APIs](../kafka/developing-with-kafka.md) section.
// Note the use of the org.oracle.okafka.clients.producer.KafkaProducer class, for Oracle TxEventQ.
80
+
returnnewKafkaProducer<String, String>(props);
81
+
}
82
+
```
83
+
84
+
The Producer bean can be autowired into Spring components to write messages to Oracle Database Transactional Event Queue topics.. For a complete example of writing data to topics, see [Producing messages to Kafka Topics](../kafka/developing-with-kafka.md#producing-messages).
85
+
86
+
### Configuring a Consumer Bean
87
+
88
+
Next, we'll configure a sample consumer bean using the org.oracle.okafka.clients.consumer.KafkaConsumer class:
// Note the use of the org.oracle.okafka.clients.consumer.KafkaConsumer class, for Oracle TxEventQ.
103
+
returnnewKafkaConsumer<>(props);
104
+
}
105
+
```
106
+
107
+
The Consumer bean can be autowired into Spring components to poll messages from Oracle Database Transactional Event Queue topics. For a complete consumer example, see [Consuming messages from Kafka topics](../kafka/developing-with-kafka.md#consuming-messages).
108
+
109
+
## Sample Application Code
110
+
111
+
The following samples provide application code using the Spring starter.
112
+
113
+
-[Oracle Spring Boot Sample for JSON Events and the Kafka Java Client for Oracle Database Transactional Event Queues](https://github.com/oracle/spring-cloud-oracle/tree/main/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events)
114
+
-[Oracle Spring Boot Sample for the Kafka Java Client for Oracle Database Transactional Event Queues](https://github.com/oracle/spring-cloud-oracle/tree/main/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-okafka)
0 commit comments