NOTE: Here we are going to do the installation on vps without dockerizing the kafka & zookeeper. Please check the section of dockerizing the services for containerised installation.
- Add an EventProducer using kafka template in authservice to save UserInfo.
- Setup the required dependencies for kafka.
- Set up the Kafka properties topic_name, server ip and port, Server Template.
- Create a EventProducer and initialize kafka template.
- Add a method to produce an event with userInfo.
- Define a kafka serializer to serialiaze the UserInfo object.
- In authservice, use the eventProducer to send the user data to kafka.
Note:
-
Kafka should be installed and running on local/server.
-
Use Spring Initializer (SpringIO) to create and setup the services with dependencies.
-
Create a UserService to consume userInfo event and add the user in the database.
- Setup a new UserService and add the required dependencies. (kafka, mysql)
- Create a consumer class to consume the event and add it into the database.
- Add a Kafka deserializer for the userinfo
- create a UserRepository to fetch and save the user.
- Setup the application properties to access mysql, kafka ( and related properties.