micronaut-projects / micronaut-kafka

Integration between Micronaut and Apache Kafka
Apache License 2.0
83 stars 104 forks source link

Kafka equivalent to HttpRequest's `@RequestScope` #1017

Open hrothwell opened 5 months ago

hrothwell commented 5 months ago

Feature description

We have the ability to make a @RequestScope bean in Micronaut which ties a bean to the current HttpRequest the server is executing on, would it be possible to do something similar for a Kafka message/batch of messages/etc?

graemerocher commented 4 months ago

probably, would require implementing a custom scope and binding the scope to a thread. Could probably use AbstractConcurrentCustomScope

hrothwell commented 3 months ago

I'll do some digging on it at some point this week if I get time, thanks for the lead as to where to look

hrothwell commented 3 months ago

I did spend some time today digging through this with mostly more questions than answers (wip branch for reference) , but to document some notes / ideas / findings / etc about it:

hrothwell commented 3 months ago

random weekend brain thoughts that I am putting down to not forget:

could it be ThreadLocal but then also have a "refresh" function on the bean that is called every poll loop?