spring but could not find any ways for that. i need to recreate a kafka streams processor bean without restarting. any idea how i can do this?
How many time and under what condition u wanna it get reloaded?
I want to reload it after an api is called so manual trigger
As i know default scope is singleton for beans...so it seems kinda funny but maybe with just using setter somewhere 🤔 ideas is to define a class and annotate it with configuration...api call changes its value and decide what happens in your beans base on that value
the problem is the bean has a signature like this public Function<Flux<Message<File>>, Tuple2<Flux<Message<FileLog>>,Flux<Message<B>>>> so it's a functional interface and i don't think i can convert it to a class so it can hold a state
I think there is a misunderstanding...i mean define something like this : @config Class stateClass{ Private boolean state; } Now in your bean class do this Class yourKafkaClass{ Private stateClass stateclass; @bean anythings a(){ If stateclass.state is true do this else do that } }
well currently it is implemented like this but it doesn't change when i update the stateClass object
Did u tried to change bean scope?
no, I was afraid it would impact the performance
I am agree...i am out😂happy with debuging
😁😁 thank you for your help
I feel that you're asking wrong question. Your goal seems to be to reconfigure kafka stream processors by api call. And you assume that bean refreshing should do this. Well, I didn't work with kafka streams in spring-boot, but based on my experience with pretty overengineered kafka (without streams) spring boot glue code and brief checking of kafka streams SB docs, I'm 99% sure that just refreshing bean won't work. The thing is that refreshing a bean just updates its instance in the beans registry. It doesn't force any users of this bean to do anything about it. And I'm sure that the code that builds topology out of all the processors you defined as beans, and starts streams processing, gets invoked only during the startup. In other words, if you refresh some processor bean, nobody will care as nobody will never inject that bean later, as this discovery/injection/build/start happens only once during startup. So, I guess, the only way would be to use kafka streams api directly, without spring-boot/cloud glue code, and rebuild the pipeline programmatically from that endpoint code.
Yeah that's what i come to conclusion with too Thanks for your response
Обсуждают сегодня