lundi 29 juin 2020

Call Controller from kafka component

I've been searching a lot about it, and the only two things I've found is that my design is possibly bad, but I doubt it is. The problem I am having is that I have Spring Kafka classes, where I have a trigger waiting for the messages that reach a topic, and when that info arrives I want to send it to my controller, and from my controller it will be taken to another microservice.

Could I autowired my controller without creating infinite instances?

Name of classes: KafkaConsumer

When kafka is activated I would like to call a method from my controller.

Code Kafka:

@Component
public class KafkaConsumer {

    private static final String TOPIC = "topic_name";


    @KafkaListener(topics = TOPIC)
    private void listen(String msg) {
        
      //Send msg to my controller
    }
}


Aucun commentaire:

Enregistrer un commentaire