'CDI Produce Bean For Each Message
We have a java (microprofile) application that listens to a Kafka topic.
The listener (consumer) class reads a message from the topic and construct a pojo from this message (via the new Message() keyword).
Our consumer, service and DAO classes are all @Dependent scoped beans.
Each message has its own different attribute values. And we create a new service instance for each message being processed.
We want to have the Message object converted to a bean in order to inject it directly in our DAO bean. The problem we are unable to overcome is: creating a producer will not be able to read message metadata since the producer method will be called at the injection point (we don't have Message object at this point).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
