We have rest-api based java service (spring REST application in Tomcat server), which is basically handling the CRUD operation against the database. Now we have a requirement to consume some kafka events to update few tables.
Is it good practice keep the kafka consumers inside the rest api based java application (or) can we have dedicated service which handles the kafka events.
Queries:
1). If we include these consumers in rest application, How Kafka consumers will behave along with rest api. for example if there is request received from rest api call & same time a kafka event is available to consume (or) already in processing.
2). If we have kafka consumer inside the rest api application, how we can gracefully deploy / rollout the code changes, Considering in rest based app we can drain the connection to the containers from load-balancers while shutting them down.
3). Scaling issues like parity mismatch between no of consumers and pods / consumer instance (i.e: During auto scaling of pods).