File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,10 @@ pip install -r requirements.txt
23
23
24
24
## Usage
25
25
26
- The Python code can be run in bash with the following
27
-
26
+ The Python code can be run in bash with the following,
27
+ in SSL security protocol:
28
28
``` bash
29
- python main.py --cert-folder ~ /kafkaCerts/ \
29
+ python main.py --security-protocol ssl -- cert-folder ~ /kafkaCerts/ \
30
30
--host kafka-< name> .aivencloud.com \
31
31
--port 13041 \
32
32
--topic-name pizza-orders \
Original file line number Diff line number Diff line change 2
2
import json
3
3
from kafka import KafkaProducer
4
4
import time
5
+ import sys
5
6
import random
6
7
import argparse
7
8
from pizzaproducer import PizzaProvider
@@ -38,7 +39,7 @@ def produce_msgs(security_protocol='SSL',
38
39
value_serializer = lambda v : json .dumps (v ).encode ('ascii' ),
39
40
key_serializer = lambda v : json .dumps (v ).encode ('ascii' )
40
41
)
41
- else :
42
+ elif security_protocol . upper () == 'SSL' :
42
43
producer = KafkaProducer (
43
44
bootstrap_servers = hostname + ':' + port ,
44
45
security_protocol = 'SSL' ,
@@ -48,6 +49,8 @@ def produce_msgs(security_protocol='SSL',
48
49
value_serializer = lambda v : json .dumps (v ).encode ('ascii' ),
49
50
key_serializer = lambda v : json .dumps (v ).encode ('ascii' )
50
51
)
52
+ else :
53
+ sys .exit ("This security protocol is not supported!" )
51
54
52
55
if nr_messages <= 0 :
53
56
nr_messages = float ('inf' )
You can’t perform that action at this time.
0 commit comments