This project demonstrates how to create a simple Java application that produces and consumes user events using Apache Kafka.
java-kafka-project
├── producer
│ ├── src
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── ProducerApp.java
│ │ │ └── resources
│ │ │ └── application.properties
│ ├── pom.xml
├── consumer
│ ├── src
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── ConsumerApp.java
│ │ │ └── resources
│ │ │ └── application.properties
│ ├── pom.xml
└── README.md
- Java 11 or higher
- Apache Kafka
- Maven
-
Clone the repository:
git clone <repository-url> cd java-kafka-project
-
Start Kafka: Follow the instructions in the Kafka documentation to start your Kafka broker.
-
Configure Producer:
- Navigate to
producer/src/main/resources/application.properties
. - Update the Kafka broker address and topic name as needed.
- Navigate to
-
Build the Producer:
cd producer mvn clean package
-
Run the Producer:
java -cp target/producer-1.0-SNAPSHOT.jar com.example.ProducerApp
-
Configure Consumer:
- Navigate to
consumer/src/main/resources/application.properties
. - Update the Kafka broker address and topic name as needed.
- Navigate to
-
Build the Consumer:
cd consumer mvn clean package
-
Run the Consumer:
java -cp target/consumer-1.0-SNAPSHOT.jar com.example.ConsumerApp
- The producer application sends user events to the specified Kafka topic.
- The consumer application listens to the same topic and processes the received events.
This project is licensed under the MIT License.