ICS sample producer and consumer
[nonrtric.git] / sample-services / ics-producer-consumer / README.md
1 <!--
2 * ========================LICENSE_START=================================
3 * O-RAN-SC
4 *
5 * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
19 -->
20 # Automatic
21 ### Using Kafka with a Java Producer and Consumer
22
23 Run the demo script
24 It will check prerequisites, build a consumer and producer, and run them with kafka and ICS.
25
26 ```shell
27 ./start.sh
28 ```
29 Or run the other script to bring up RedPanda on port 8888 and NONRTRIC control panel UI on port 8181
30
31 ```shell
32 ./red.sh
33 ```
34
35 For a faster execution you can add:
36
37 --skip-build to skip creating the app jar and building the docker images
38
39 --no-console to skip running RedPanda and NONRTRIC control panel
40
41 ```shell
42 ./red.sh --skip-build --no-console
43 ```
44 # Manual
45 ### Run Kafka in a container
46
47 ```shell
48 docker-compose up -d kafka-zkless
49 ```
50
51 ### Starting the REST application individually
52
53 In a new terminal window:
54
55 ```shell
56 mvn spring-boot:run
57 ```
58
59 ### Starting a producer
60
61 ```shell
62 sh ./runproducer.sh
63 ```
64
65 ### Starting a Consumer
66
67 ```shell
68 sh ./runproducer.sh
69 ```
70
71 ## Reading the logs
72
73 A sample of the output is as follows:
74
75 ```
76 Demo Producer Docker logs
77
78 2024-04-02 12:48:05 INFO  c.d.p.p.SimpleProducer:141 - {"bootstrapServers":"kafka-zkless:9092","topic":"mytopic","source":"com.demo.producer.producer.SimpleProducer","message":"ygHwxXSIxW","key":"f8f1a7a7-a78e-4c7d-9b8d-108bb0cc9e2c"}
79 2024-04-02 12:48:06 INFO  c.d.p.p.SimpleProducer:141 - {"bootstrapServers":"kafka-zkless:9092","topic":"mytopic","source":"com.demo.producer.producer.SimpleProducer","message":"KNIbP10zfN","key":"b058d00f-bbcd-4d2c-936b-6327847d4c2a"}
80 2024-04-02 12:48:07 INFO  c.d.p.p.SimpleProducer:141 - {"bootstrapServers":"kafka-zkless:9092","topic":"mytopic","source":"com.demo.producer.producer.SimpleProducer","message":"V6fH1NkdeH","key":"ae1a83a3-d8a7-40c8-9d98-529230f8b585"}
81 2024-04-02 12:48:08 INFO  c.d.p.p.SimpleProducer:141 - {"bootstrapServers":"kafka-zkless:9092","topic":"mytopic","source":"com.demo.producer.producer.SimpleProducer","message":"m76qvRFh6f","key":"abccde52-fa72-4fd4-99ab-5bc21514d825"}
82 2024-04-02 12:48:09 INFO  c.d.p.p.SimpleProducer:141 - {"bootstrapServers":"kafka-zkless:9092","topic":"mytopic","source":"com.demo.producer.producer.SimpleProducer","message":"t7FJYnFr43","key":"0602239e-34e9-45a6-a04a-3c67b4c7d9e4"}
83
84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
85
86 Demo Consumer Docker logs
87
88 2024-04-02 12:48:05 INFO  c.d.c.c.SimpleConsumer:158 - {"message":"Topic: mytopicMessage: ygHwxXSIxW"}
89 2024-04-02 12:48:06 INFO  c.d.c.c.SimpleConsumer:158 - {"message":"Topic: mytopicMessage: KNIbP10zfN"}
90 2024-04-02 12:48:07 INFO  c.d.c.c.SimpleConsumer:158 - {"message":"Topic: mytopicMessage: V6fH1NkdeH"}
91 2024-04-02 12:48:08 INFO  c.d.c.c.SimpleConsumer:158 - {"message":"Topic: mytopicMessage: m76qvRFh6f"}
92 2024-04-02 12:48:09 INFO  c.d.c.c.SimpleConsumer:158 - {"message":"Topic: mytopicMessage: t7FJYnFr43"}
93
94 ++++++++++++++++++++++++++++++++++++++++++++++++++++
95
96 ICS logs
97
98 2024-04-02T12:48:05.615Z DEBUG 1 --- [or-http-epoll-2] o.o.i.c.r1producer.ProducerCallbacks     : Job subscription 1 started OK 1
99 2024-04-02T12:48:05.820Z DEBUG 1 --- [io-8083-exec-10] o.o.i.repository.InfoTypeSubscriptions   : Added type status subscription 1
100 ```
101
102 The script will fail (exit 1) if there are anny ERRORS logged in the kafka-producer and kafka-consumer.