Start Zookeeper container and expose port 2181:
docker run -p 2181:2181 zookeeper
Start Kafka container, expose port 9092, and set up environment variables:
docker run -p 9092:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=<PRIVATE_IP>:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://<PRIVATE_IP>:9092 \
-e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
confluentinc/cp-kafka
Replace <PRIVATE_IP>
with the private IP address of your machine.
Create a Kafka topic named "rider-updates" with 2 partitions:
node admin.js
Run a Kafka consumer:
node consumer.js <GROUP_NAME>
Replace <GROUP_NAME>
with the name of the consumer group.
Run a Kafka producer:
node producer.js
Enter rider name and location as prompted, e.g., tony south
, tony north
.