Code produced to check the technical feasibility of reading a topic events from Kafka from java code. This project is the part that consumes the events in Kafka. This code can be used to read events.
Explore Kafka docs
View Demo
·
Report Bug
·
Request Feature
Code produced to check the technical feasibility of reading a topic events from Kafka from java code.
This project is the part that consumes the events in Kafka.
- springframework.boot: to save time and quickly create an application executable on RHEL
- org.apache.kafka: which allows to open the connection with the Kafka machine, connect to topics and read their content
- springframework.kafka: which saves time for everything concerns the use of Kafka in a Spring project
- a src/main/resources/application.properties file which contains the address of the Kafka machine and the name of the topic to listen to
- src/main/java/com/ame/messages/SubscribedReader.java: which is the main java class, it launch the connection to the Kafka machine and to the topic and especially it realizes topic reading and displaying System.out for each messages
- src/main/java/com/ame/messages/config/ConsumerChannelConfig.java: which is the java class in which we find the methods that perform access to the Kafka machine and to the topic
The project opens on Eclipse or IntelliJ.
To get a local copy up and running follow these simple steps.
- Clone the repo
git clone https://github.com/AntoineMeheut/kafka_consumer
mvn clean install -U
- Copy the sources on an RHEL, go to the directory where is located the pom of the project namely kafka_consumer and type the command:
mvn clean install -U spring-boot:run -Dspring.kafka.consumer.group-id="consumer1" -Drun.arguments="AME"
- the argument spring.kafka.consumer.group-id allows to execute several consumers
- the argument run.arguments allows you to choose what type of event you want listen
- to use method 1: you must have maven on the RHEL machine
- Build a jar and copy it to the RHEL machine, go to the directory where the jar is and type the following command:
nohup java -jar kafka_consumer.jar -Dspring.kafka.consumer.group-id="consumer1" -Drun.arguments="AME" &
See the Project for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the GNU General Public License v3.0 License. See LICENSE
for more information.
If you want to contact me just clic
Project Link: https://github.com/AntoineMeheut/kafka_consumer