Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# @refernence:
# https://www.alibabacloud.com/help/zh/message-queue-for-apache-kafka/latest/sdk-for-python-send-and-consume-messages-by-using-an-ssl-endpoint-with-plain-authentication
# https://github.com/AliwareMQ/aliware-kafka-demos
#
FROM ubuntu:22.04

ENV ALI_KAFKA_BOOTSTRAP_SERVERS="kafka-1:9092,kafka-2:9092.kafka-3:9092"
ENV ALI_KAFKA_TOPIC_NAME="YOUR_TOPIC_NAME"
ENV ALI_KAFKA_CONSUMER_ID="YOUR_GROUP_ID"
ENV ALI_KAFKA_DEMOS_REPO="https://github.com/AliwareMQ/aliware-kafka-demos"

RUN apt-get update \
&& apt-get -yq install \
git \
wget \
python3 \
python3-pip \
&& pip install confluent-kafka==1.9.2 \
&& wget https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20220826/ytsw/only-4096-ca-cert

ADD . /aliware-kafka-demos/
WORKDIR /aliware-kafka-demos/
CMD ["/bin/sleep", "infinity"]
12 changes: 9 additions & 3 deletions kafka-confluent-python-demo/vpc/setting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import os

bootstrap_servers = os.environ.get('ALI_KAFKA_BOOTSTRAP_SERVERS', 'kafka-1:9092,kafka-2:9092.kafka-3:9092').split(',')
topic_name = os.environ.get('ALI_KAFKA_TOPIC_NAME', 'YOUR_TOPIC_NAME')
consumer_id = os.environ.get('ALI_KAFKA_CONSUMER_ID', 'YOUR_GROUP_ID')

kafka_setting = {
'bootstrap_servers': 'xxx:xx,xxx:xx',
'topic_name': 'xxx',
'group_name': 'xxx'
'bootstrap_servers': bootstrap_servers,
'topic_name': topic_name,
'group_name': consumer_id,
}