Two simple .net core console apps (producer & consumer) using Kafka as a message broker. As addition you can use Confluent Control Center by using Option 2 (see below) with Docker.
Install Kafka (latest version) on your local machine: [https://kafka.apache.org/downloads]
bin\windows\zookeeper-server-start.bat config/zookeeper.properties
bin\windows\kafka-server-start.bat config/server.properties
git clone https://github.com/confluentinc/examples.git
Make sure you have at least 8192MB Memory allocated in docker (Settings, Advanced).
cd cp-all-in-one
docker-compose up -d --build
docker-compose ps
All states should have the value 'Up'
Go to a webbrowser and start Confluent Control Center: localhost:9021
Under 'topics' you can create a new topic called 'testTopic' with 0 partitions.
cd bookstore-producer
dotnet run args[-newmsg, -topic, -partition] (i.e. dotnet run -newmsg 24 -topic testTopicP12 -partition 12
)
The result should be like that:
- Press Ctrl+C to exit
- Delivered 'This is a test: 5' to: testTopicP12 [[5]] @19
- Delivered 'This is a test: 2' to: testTopicP12 [[2]] @14
- Delivered 'This is a test: 17' to: testTopicP12 [[5]] @21
- ...
cd bookstore-consumer
dotnet run args[-topic, -group] (i.e. dotnet run -topic testTopicP12 -group testTopic12
)
The result should be like that:
- Press Ctrl+C to exit
- Topic: testTopicP12
- Group: testTopic12
- Message 'This is a test: 22' at: 'testTopicP12 [[10]] @10'.
- Message 'This is a test: 10' at: 'testTopicP12 [[10]] @11'.
- Message 'This is a test: 22' at: 'testTopicP12 [[10]] @12'.
- ...