Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@PollScope - specialized @ThreadLocal beans to refresh each poll #1041

Draft
wants to merge 7 commits into
base: 5.5.x
Choose a base branch
from

Conversation

hrothwell
Copy link

Initial attempt at addressing #1017

  • Create new PollScope annotation which is essentially just ThreadLocal but renamed for gaining access via qualifiers
  • Add refreshPollScopeBeans() to KafkaConsumerProcessor - intending to refresh all PollScope beans for the current consumer / thread that is executing
  • call to refreshPollScopeBeans from ConsumerState right before record processing begins

I am definitely unsure if refreshPollScopeBeans will behave even remotely closely to how I am hoping (hence the TODO above it), and I appear to be unable to run any tests locally (have a docker env setup, can tell that it pulls and starts a kafka container, but appears to never inject or set kafka.bootstrap.servers). All things I will/plan to look into but still wanted to get this up as a draft for now

@graemerocher
Copy link
Contributor

so I am unsure as well since this PR doesn't run bean destruction hooks. The question is if you want to run those hooks at the end of the execution or only when the application shutdowns

@graemerocher
Copy link
Contributor

Also sounds like you want beans recreated. This PR will probably not work for constructor injection, calling refresh will reinfect fields/methods but not recreate the instances

@hrothwell
Copy link
Author

Also sounds like you want beans recreated. This PR will probably not work for constructor injection, calling refresh will reinfect fields/methods but not recreate the instances

Really I don't think that for my exact current use case I care about recreating the bean, just that the values of it are refreshed. I figured that just recreating the beans might be the easiest and best way for the long term to handle that. I am working on another solution for my own use case and what I come up with for that might lead to more ideas / use cases here. Will include some more details after I figure out some of those details and if it actually works in my use case I am working around.

@hrothwell
Copy link
Author

example branch of a solution that albeit technically works for my use case I described, feels like there could be some better solution that would also benefit others or be more reusable.

The plan with that approach would be to annotate our function that handles message processing with @RefreshesThreadLocal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants