Skip to content

Commit 4d6e361

Browse files
authored
Merge pull request #52 from oracle/okafka-example-23.4
Fix Okafka example 23.4
2 parents 88ca668 + 3415f48 commit 4d6e361

File tree

19 files changed

+194
-1084
lines changed

19 files changed

+194
-1084
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ clients/.project
2727
clients/.settings/
2828
examples/.project
2929
examples/.settings/
30+
examples/ojdbc.properties
3031
examples/consumer/.classpath
3132
examples/consumer/.project
3233
examples/consumer/.settings/

README.md

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ To run `OKafka application` against Oracle Database, a database user must be cre
2222

2323
```roomsql
2424
create user <user> identified by <password>
25-
GRANT CONNECT , RESOURCE to user;
26-
GRANT UNLIMITED TABLESPACE to user;
25+
26+
GRANT AQ_USER_ROLE to user;
27+
GRANT CONNECT, RESOURCE, unlimited tablespace to user;
2728
GRANT EXECUTE on DBMS_AQ to user;
2829
GRANT EXECUTE on DBMS_AQADM to user;
2930
GRANT EXECUTE on DBMS_AQIN to user;
@@ -34,7 +35,8 @@ GRANT SELECT on GV_$INSTANCE to user;
3435
GRANT SELECT on GV_$LISTENER_NETWORK to user;
3536
GRANT SELECT on GV_$PDBS to user;
3637
GRANT SELECT on USER_QUEUE_PARTITION_ASSIGNMENT_TABLE to user;
37-
exec DBMS_AQADM.GRANT_PRIV_FOR_RM_PLAN('user');
38+
GRANT SELECT on SYS.DBA_RSRC_PLAN_DIRECTIVES to user;
39+
EXEC DBMS_AQADM.GRANT_PRIV_FOR_RM_PLAN('user');
3840
```
3941

4042
Note:
@@ -134,29 +136,13 @@ gradle javadoc
134136

135137
## Examples
136138

137-
Repository contains 7 common OKafka application examples in `examples` folder.
138-
139-
`1. CreateTopic.java` -
140-
Connects to Oracle Database and create a topic TXEQ with 10 partitions with default retention time of 7 days.
141-
142-
`2. DeleteTopic.java`
143-
Deletes already created OKafka topic.
144-
145-
`3. SimpleProducer.java`
146-
Produces 100 messages into TxEQ topic.
147-
148-
`4. SimpleConsumer.java`
149-
Consumes 100 messages from TxEQ topic.
150-
151-
`5. TransactionalProducer.java`
152-
Retrieves the Oracle Database Connection object from OKafka producer. Atomically performs a DML operation and sends a record.
153-
154-
`6. TransactionalConsumer.java`
155-
Retrieves the Oracle Database Connection object from OKafka consumer. Atomically consumes a batch of records and perform DML operation for each record.
139+
Repository contains 2 common OKafka application examples in `examples` folder.
156140

141+
`1. ProducerOKafka.java`
142+
Produces 10 messages into TxEQ topic.
157143

158-
`7. TransactionalProduceConsume.java`
159-
Atomically consumes a batch of messages from TXEQ topic using OKafka Consumer, processes records from the batch and produces them in the tpic TxEQ_2 using OKafka Producer. To achieve atomicity for this these consume-process-produce operations, application retrieves the Oracle Database Connection object from OKafka Consumer and pass it to create an OKafka Producer.
144+
`2. ConsumerOKafka.java`
145+
Consumes 10 messages from TxEQ topic.
160146

161147
## Kafka Java Client APIs supported
162148

build.gradle

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ allprojects {
2828
options.windowTitle = "Oracle Database Transactional Event Queues Java API Reference"
2929
options.header = """<b>Oracle&reg; Database Transactional Event Queues Java API Reference<br>23ai</b><br>FF46992-04<br>"""
3030
options.bottom = """<center><small>Copyright &copy; 2001, 2024, Oracle and/or its affiliates. All rights reserved.<small></center><p><small><br></small></p>"""
31-
}
31+
}
3232
}
3333

3434
ext {
35-
gradleVersion = '7.3'
36-
minJavaVersion = JavaVersion.VERSION_1_8
35+
gradleVersion = '8.8'
36+
minJavaVersion = JavaVersion.VERSION_17
3737

3838
mavenUrl = project.hasProperty('mavenUrl') ? project.mavenUrl : ''
3939
mavenUsername = project.hasProperty('mavenUsername') ? project.mavenUsername : ''
@@ -42,41 +42,41 @@ ext {
4242

4343
project(':clients') {
4444
apply plugin : 'java-library'
45-
45+
4646
sourceCompatibility = minJavaVersion
4747
targetCompatibility = minJavaVersion
48-
48+
4949
sourceSets {
50-
main {
51-
java {
52-
srcDir 'src/main/java'
53-
exclude 'tests/**'
54-
exclude 'test/**'
55-
}
56-
}
57-
}
50+
main {
51+
java {
52+
srcDir 'src/main/java'
53+
exclude 'tests/**'
54+
exclude 'test/**'
55+
}
56+
}
57+
}
5858

59-
println 'Creating okafka-23.4.0.0.jar'
59+
println 'Building okafka 23.4.0.0 Java API jar'
6060

6161
dependencies {
6262

63-
// These dependencies are used by the application.
64-
implementation group: 'com.oracle.database.jdbc', name: 'ojdbc11', version: '23.4.0.24.05'
65-
implementation group: 'com.oracle.database.messaging', name: 'aqapi', version: '23.3.0.0'
66-
implementation group: 'javax.transaction', name: 'jta', version: '1.1'
67-
implementation group: 'javax.jms', name: 'javax.jms-api', version: '2.0'
68-
implementation group: 'com.oracle.database.security', name: 'oraclepki', version: '23.4.0.24.05'
69-
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.0-alpha0'
70-
implementation group: 'org.apache.kafka', name: 'kafka-clients', version: '3.7.1'
71-
// Use JUnit test framework
72-
implementation group: 'junit', name: 'junit', version: '4.12'
73-
74-
// Test dependencies
75-
testImplementation group: 'org.easymock', name: 'easymock', version: '3.6'
76-
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0-beta.5'
77-
testImplementation group: 'org.powermock', name: 'powermock-api-support', version: '2.0.5'
78-
testImplementation group: 'org.powermock', name: 'powermock-api-easymock', version: '2.0.0-beta.5'
79-
63+
// These dependencies are used by the application.
64+
implementation group: 'com.oracle.database.jdbc', name: 'ojdbc11', version: '23.4.0.24.05'
65+
implementation group: 'com.oracle.database.messaging', name: 'aqapi', version: '23.3.0.0'
66+
implementation group: 'javax.transaction', name: 'jta', version: '1.1'
67+
implementation group: 'javax.jms', name: 'javax.jms-api', version: '2.0'
68+
implementation group: 'com.oracle.database.security', name: 'oraclepki', version: '23.4.0.24.05'
69+
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.0-alpha0'
70+
implementation group: 'org.apache.kafka', name: 'kafka-clients', version: '3.7.1'
71+
// Use JUnit test framework
72+
implementation group: 'junit', name: 'junit', version: '4.12'
73+
74+
// Test dependencies
75+
testImplementation group: 'org.easymock', name: 'easymock', version: '3.6'
76+
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0-beta.5'
77+
testImplementation group: 'org.powermock', name: 'powermock-api-support', version: '2.0.5'
78+
testImplementation group: 'org.powermock', name: 'powermock-api-easymock', version: '2.0.0-beta.5'
79+
8080
}
8181

8282
javadoc {
@@ -87,18 +87,21 @@ project(':clients') {
8787
}
8888

8989
tasks.named('jar') {
90-
description('Creating JAR okafka-23.4.0.0.jar ')
90+
description('Generates okafka 23.4.0.0 API jar ')
9191
archiveBaseName = 'okafka'
9292
archiveVersion = '23.4.0.0'
93+
9394
from "${rootProject.projectDir}/LICENSE.txt"
9495
from "${rootProject.projectDir}/NOTICE"
9596

96-
manifest {
97-
attributes (
98-
'Version': '23.4.0.0',
99-
'Build-Time-ISO-8601':new Date().format("yyyy-MM-dd HH:mm:ss")
100-
)
101-
}
97+
manifest {
98+
attributes (
99+
'Implementation-Title' : 'okafka',
100+
'Implementation-Version': project.version,
101+
'Version': '23.4.0.0',
102+
'Build-Time-ISO-8601':new Date().format("yyyy-MM-dd HH:mm:ss")
103+
)
104+
}
102105
}
103106

104107
tasks.register('fullJar', Jar) {
@@ -107,7 +110,7 @@ project(':clients') {
107110

108111
manifest {
109112
attributes( 'Implementation-Title' : 'okafka',
110-
'Implementation-Version': project.version)
113+
'Implementation-Version': project.version)
111114
}
112115

113116
from "${rootProject.projectDir}/LICENSE.txt"
@@ -137,6 +140,7 @@ project(':examples:consumer') {
137140
implementation project(':clients')
138141
implementation group: 'com.oracle.database.security', name: 'oraclepki', version: '23.4.0.24.05'
139142
implementation group: 'org.apache.kafka', name: 'kafka-clients', version: '3.7.1'
143+
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.5.6'
140144
}
141145

142146

@@ -150,14 +154,14 @@ project(':examples:consumer') {
150154

151155
manifest {
152156
attributes( 'Implementation-Title' : 'okafka consumer',
153-
'Implementation-Version': project.version)
157+
'Implementation-Version': project.version)
154158
}
155159
}
156160

157161
tasks.named('run') {
158-
description('Run okafka client consumer')
162+
description('Run okafka client simple consumer')
159163
application {
160-
mainClass = 'org.oracle.okafka.examples.Consumer'
164+
mainClass = 'org.oracle.okafka.examples.ConsumerOKafka'
161165
}
162166
}
163167
}
@@ -174,10 +178,11 @@ project(':examples:producer') {
174178
implementation project(':clients')
175179
implementation group: 'com.oracle.database.security', name: 'oraclepki', version: '23.4.0.24.05'
176180
implementation group: 'org.apache.kafka', name: 'kafka-clients', version: '3.7.1'
181+
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.5.6'
177182
}
178183

179184
tasks.named('jar') {
180-
description('Generates okafka client producer jar ')
185+
description('Generates okafka client simple producer jar ')
181186
archiveBaseName = 'okafka'
182187
archiveClassifier = 'producer'
183188

@@ -186,14 +191,14 @@ project(':examples:producer') {
186191

187192
manifest {
188193
attributes( 'Implementation-Title' : 'okafka producer',
189-
'Implementation-Version': project.version)
194+
'Implementation-Version': project.version)
190195
}
191196
}
192197

193198
tasks.named('run') {
194-
description('Run okafka client producer')
199+
description('Run okafka client simple producer')
195200
application {
196-
mainClass = 'org.oracle.okafka.examples.Producer'
201+
mainClass = 'org.oracle.okafka.examples.ProducerOKafka'
197202
}
198203
}
199204
}

examples/common/src/main/java/org/oracle/okafka/examples/CreateTopic.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

examples/common/src/main/java/org/oracle/okafka/examples/DeleteTopic.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)