Skip to content

Commit 57a3e69

Browse files
yazebochanRoman Nedzvetskiygermanosin
authored
Added message sending (#85)
* Added message sending * sent message to kafka * renamed docker service * renamed message file * Changed message to json * fixed docker compose and messages Co-authored-by: Roman Nedzvetskiy <[email protected]> Co-authored-by: German Osin <[email protected]>
1 parent 5ff3eaf commit 57a3e69

File tree

3 files changed

+149
-76
lines changed

3 files changed

+149
-76
lines changed

docker/kafka-clusters-only.yaml

Lines changed: 28 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,113 +5,67 @@ services:
55
zookeeper0:
66
image: confluentinc/cp-zookeeper:5.1.0
77
environment:
8-
ZOOKEEPER_CLIENT_PORT: 2183
8+
ZOOKEEPER_CLIENT_PORT: 2181
99
ZOOKEEPER_TICK_TIME: 2000
10-
ports:
11-
- 2183:2183
1210

1311
kafka0:
1412
image: confluentinc/cp-kafka:5.1.0
1513
depends_on:
1614
- zookeeper0
17-
ports:
18-
- 29091:29091
19-
- 9997:9997
2015
environment:
2116
KAFKA_BROKER_ID: 1
22-
KAFKA_ZOOKEEPER_CONNECT: zookeeper0:2183
23-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka0:9092,PLAINTEXT_HOST://localhost:29091 #,PLAIN://kafka0:29090
24-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT #,PLAIN:PLAINTEXT
17+
KAFKA_ZOOKEEPER_CONNECT: zookeeper0:2181
18+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka0:29092,PLAINTEXT_HOST://localhost:9092
19+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
2520
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
26-
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 2
27-
JMX_PORT: 9997
28-
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.rmi.port=9997
29-
30-
kafka01:
31-
image: confluentinc/cp-kafka:5.1.0
32-
depends_on:
33-
- zookeeper0
34-
ports:
35-
- 29093:29093
36-
- 9999:9999
37-
environment:
38-
KAFKA_BROKER_ID: 2
39-
KAFKA_ZOOKEEPER_CONNECT: zookeeper0:2183
40-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka01:9092,PLAINTEXT_HOST://localhost:29093,PLAIN://kafka0:29090
41-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT,PLAIN:PLAINTEXT
42-
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
43-
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 2
21+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
4422
JMX_PORT: 9997
45-
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.rmi.port=9997
46-
47-
kafka-init-topics0:
48-
image: confluentinc/cp-kafka:5.1.0
49-
depends_on:
50-
- kafka0
51-
command: "bash -c 'echo Waiting for Kafka to be ready... && \
52-
cub kafka-ready -b kafka0:9092 1 20 && \
53-
kafka-topics --create --topic users --partitions 2 --replication-factor 2 --if-not-exists --zookeeper zookeeper0:2183 && \
54-
kafka-topics --create --topic messages --partitions 3 --replication-factor 2 --if-not-exists --zookeeper zookeeper0:2183'"
55-
environment:
56-
KAFKA_BROKER_ID: ignored
57-
KAFKA_ZOOKEEPER_CONNECT: ignored
58-
networks:
59-
- default
23+
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka0 -Dcom.sun.management.jmxremote.rmi.port=9997
6024

6125
zookeeper1:
6226
image: confluentinc/cp-zookeeper:5.1.0
6327
environment:
64-
ZOOKEEPER_CLIENT_PORT: 2182
28+
ZOOKEEPER_CLIENT_PORT: 2181
6529
ZOOKEEPER_TICK_TIME: 2000
66-
ports:
67-
- 2182:2182
6830

6931
kafka1:
7032
image: confluentinc/cp-kafka:5.1.0
7133
depends_on:
7234
- zookeeper1
73-
ports:
74-
- 29092:29092
75-
- 9998:9998
7635
environment:
7736
KAFKA_BROKER_ID: 1
78-
KAFKA_ZOOKEEPER_CONNECT: zookeeper1:2182
79-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9092,PLAINTEXT_HOST://localhost:29092,PLAIN://localhost:29090
80-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT,PLAIN:PLAINTEXT
37+
KAFKA_ZOOKEEPER_CONNECT: zookeeper1:2181
38+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:29092,PLAINTEXT_HOST://localhost:9093
39+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
8140
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
8241
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
83-
JMX_PORT: 9998
84-
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.rmi.port=9998
85-
86-
kafka-init-topics1:
87-
image: confluentinc/cp-kafka:5.1.0
88-
depends_on:
89-
- kafka1
90-
command: "bash -c 'echo Waiting for Kafka to be ready... && \
91-
cub kafka-ready -b kafka1:9092 20 && \
92-
kafka-topics --create --topic secondUsers --partitions 3 --replication-factor 2 --if-not-exists --zookeeper zookeeper1:2182 && \
93-
kafka-topics --create --topic secondMessages --partitions 2 --replication-factor 2 --if-not-exists --zookeeper zookeeper1:2182'"
94-
environment:
95-
KAFKA_BROKER_ID: ignored
96-
KAFKA_ZOOKEEPER_CONNECT: ignored
97-
networks:
98-
- default
42+
JMX_PORT: 9997
43+
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka1 -Dcom.sun.management.jmxremote.rmi.port=9997
9944

10045
schemaregistry0:
10146
image: confluentinc/cp-schema-registry:5.1.0
10247
depends_on:
10348
- zookeeper0
10449
- kafka0
105-
- kafka01
106-
ports:
107-
- 8085:8085
10850
environment:
109-
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: PLAINTEXT://kafka0:9092,PLAINTEXT://kafka01:9092
110-
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: zookeeper0:2183
51+
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: PLAINTEXT://kafka0:29092
52+
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: zookeeper0:2181
11153
SCHEMA_REGISTRY_KAFKASTORE_SECURITY_PROTOCOL: PLAINTEXT
112-
SCHEMA_REGISTRY_HOST_NAME: schemaregistry
113-
SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8085
54+
SCHEMA_REGISTRY_HOST_NAME: schemaregistry0
55+
SCHEMA_REGISTRY_LISTENERS: http://schemaregistry0:8085
11456

11557
SCHEMA_REGISTRY_SCHEMA_REGISTRY_INTER_INSTANCE_PROTOCOL: "http"
11658
SCHEMA_REGISTRY_LOG4J_ROOT_LOGLEVEL: INFO
11759
SCHEMA_REGISTRY_KAFKASTORE_TOPIC: _schemas
60+
61+
kafka-init-topics:
62+
image: confluentinc/cp-kafka:5.1.0
63+
volumes:
64+
- ./message.json:/data/message.json
65+
depends_on:
66+
- kafka1
67+
command: "bash -c 'echo Waiting for Kafka to be ready... && \
68+
cub kafka-ready -b kafka1:29092 1 30 && \
69+
kafka-topics --create --topic second.users --partitions 3 --replication-factor 1 --if-not-exists --zookeeper zookeeper1:2181 && \
70+
kafka-topics --create --topic second.messages --partitions 2 --replication-factor 1 --if-not-exists --zookeeper zookeeper1:2181 && \
71+
kafka-console-producer --broker-list kafka1:29092 -topic second.users < /data/message.json'"

docker/kafka-ui.yaml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ services:
1313
- kafka0
1414
- kafka1
1515
- schemaregistry0
16-
command: [ "java", "-jar", "kafka-ui-api.jar", "--spring.profiles.active=sdp"]
16+
environment:
17+
KAFKA_CLUSTERS_0_NAME: local
18+
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka0:29092
19+
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper0:2181
20+
KAFKA_CLUSTERS_0_SCHEMAREGISTRY: http://schemaregistry0:8085
21+
KAFKA_CLUSTERS_1_NAME: secondLocal
22+
KAFKA_CLUSTERS_1_BOOTSTRAPSERVERS: kafka1:29092
23+
KAFKA_CLUSTERS_1_ZOOKEEPER: zookeeper1:2181
1724

1825
zookeeper0:
1926
image: confluentinc/cp-zookeeper:5.1.0
@@ -48,7 +55,7 @@ services:
4855
environment:
4956
KAFKA_BROKER_ID: 1
5057
KAFKA_ZOOKEEPER_CONNECT: zookeeper1:2181
51-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:29092,PLAINTEXT_HOST://localhost:9092
58+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:29092,PLAINTEXT_HOST://localhost:9093
5259
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
5360
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
5461
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
@@ -70,3 +77,15 @@ services:
7077
SCHEMA_REGISTRY_SCHEMA_REGISTRY_INTER_INSTANCE_PROTOCOL: "http"
7178
SCHEMA_REGISTRY_LOG4J_ROOT_LOGLEVEL: INFO
7279
SCHEMA_REGISTRY_KAFKASTORE_TOPIC: _schemas
80+
81+
kafka-init-topics:
82+
image: confluentinc/cp-kafka:5.1.0
83+
volumes:
84+
- ./message.json:/data/message.json
85+
depends_on:
86+
- kafka1
87+
command: "bash -c 'echo Waiting for Kafka to be ready... && \
88+
cub kafka-ready -b kafka1:29092 1 30 && \
89+
kafka-topics --create --topic second.users --partitions 3 --replication-factor 1 --if-not-exists --zookeeper zookeeper1:2181 && \
90+
kafka-topics --create --topic second.messages --partitions 2 --replication-factor 1 --if-not-exists --zookeeper zookeeper1:2181 && \
91+
kafka-console-producer --broker-list kafka1:29092 -topic second.users < /data/message.json'"

docker/message.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{"message":"hello1","destination":"kafka2"}
2+
{"message":"hello2","destination":"kafka2"}
3+
{"message":"hello3","destination":"kafka2"}
4+
{"message":"hello4","destination":"kafka2"}
5+
{"message":"hello5","destination":"kafka2"}
6+
{"message":"hello6","destination":"kafka2"}
7+
{"message":"hello7","destination":"kafka2"}
8+
{"message":"hello8","destination":"kafka2"}
9+
{"message":"hello9","destination":"kafka2"}
10+
{"message":"hello10","destination":"kafka2"}
11+
{"message":"hello11","destination":"kafka2"}
12+
{"message":"hello12","destination":"kafka2"}
13+
{"message":"hello13","destination":"kafka2"}
14+
{"message":"hello14","destination":"kafka2"}
15+
{"message":"hello15","destination":"kafka2"}
16+
{"message":"hello16","destination":"kafka2"}
17+
{"message":"hello17","destination":"kafka2"}
18+
{"message":"hello18","destination":"kafka2"}
19+
{"message":"hello19","destination":"kafka2"}
20+
{"message":"hello20","destination":"kafka2"}
21+
{"message":"hello21","destination":"kafka2"}
22+
{"message":"hello22","destination":"kafka2"}
23+
{"message":"hello23","destination":"kafka2"}
24+
{"message":"hello24","destination":"kafka2"}
25+
{"message":"hello25","destination":"kafka2"}
26+
{"message":"hello26","destination":"kafka2"}
27+
{"message":"hello27","destination":"kafka2"}
28+
{"message":"hello28","destination":"kafka2"}
29+
{"message":"hello29","destination":"kafka2"}
30+
{"message":"hello30","destination":"kafka2"}
31+
{"message":"hello31","destination":"kafka2"}
32+
{"message":"hello32","destination":"kafka2"}
33+
{"message":"hello33","destination":"kafka2"}
34+
{"message":"hello34","destination":"kafka2"}
35+
{"message":"hello35","destination":"kafka2"}
36+
{"message":"hello36","destination":"kafka2"}
37+
{"message":"hello37","destination":"kafka2"}
38+
{"message":"hello38","destination":"kafka2"}
39+
{"message":"hello39","destination":"kafka2"}
40+
{"message":"hello40","destination":"kafka2"}
41+
{"message":"hello41","destination":"kafka2"}
42+
{"message":"hello42","destination":"kafka2"}
43+
{"message":"hello43","destination":"kafka2"}
44+
{"message":"hello44","destination":"kafka2"}
45+
{"message":"hello45","destination":"kafka2"}
46+
{"message":"hello46","destination":"kafka2"}
47+
{"message":"hello47","destination":"kafka2"}
48+
{"message":"hello48","destination":"kafka2"}
49+
{"message":"hello49","destination":"kafka2"}
50+
{"message":"hello50","destination":"kafka2"}
51+
{"message":"hello51","destination":"kafka2"}
52+
{"message":"hello52","destination":"kafka2"}
53+
{"message":"hello53","destination":"kafka2"}
54+
{"message":"hello54","destination":"kafka2"}
55+
{"message":"hello55","destination":"kafka2"}
56+
{"message":"hello56","destination":"kafka2"}
57+
{"message":"hello57","destination":"kafka2"}
58+
{"message":"hello58","destination":"kafka2"}
59+
{"message":"hello59","destination":"kafka2"}
60+
{"message":"hello60","destination":"kafka2"}
61+
{"message":"hello61","destination":"kafka2"}
62+
{"message":"hello62","destination":"kafka2"}
63+
{"message":"hello63","destination":"kafka2"}
64+
{"message":"hello64","destination":"kafka2"}
65+
{"message":"hello65","destination":"kafka2"}
66+
{"message":"hello66","destination":"kafka2"}
67+
{"message":"hello67","destination":"kafka2"}
68+
{"message":"hello68","destination":"kafka2"}
69+
{"message":"hello69","destination":"kafka2"}
70+
{"message":"hello70","destination":"kafka2"}
71+
{"message":"hello71","destination":"kafka2"}
72+
{"message":"hello72","destination":"kafka2"}
73+
{"message":"hello73","destination":"kafka2"}
74+
{"message":"hello74","destination":"kafka2"}
75+
{"message":"hello75","destination":"kafka2"}
76+
{"message":"hello76","destination":"kafka2"}
77+
{"message":"hello77","destination":"kafka2"}
78+
{"message":"hello78","destination":"kafka2"}
79+
{"message":"hello79","destination":"kafka2"}
80+
{"message":"hello80","destination":"kafka2"}
81+
{"message":"hello81","destination":"kafka2"}
82+
{"message":"hello82","destination":"kafka2"}
83+
{"message":"hello83","destination":"kafka2"}
84+
{"message":"hello84","destination":"kafka2"}
85+
{"message":"hello85","destination":"kafka2"}
86+
{"message":"hello86","destination":"kafka2"}
87+
{"message":"hello87","destination":"kafka2"}
88+
{"message":"hello88","destination":"kafka2"}
89+
{"message":"hello89","destination":"kafka2"}
90+
{"message":"hello90","destination":"kafka2"}
91+
{"message":"hello91","destination":"kafka2"}
92+
{"message":"hello92","destination":"kafka2"}
93+
{"message":"hello93","destination":"kafka2"}
94+
{"message":"hello94","destination":"kafka2"}
95+
{"message":"hello95","destination":"kafka2"}
96+
{"message":"hello96","destination":"kafka2"}
97+
{"message":"hello97","destination":"kafka2"}
98+
{"message":"hello98","destination":"kafka2"}
99+
{"message":"hello99","destination":"kafka2"}
100+
{"message":"hello100","destination":"kafka2"}

0 commit comments

Comments
 (0)