Answer the question
In order to leave comments, you need to log in
How to declare a service scope so that when called in the RabbitListener, the service is re-initialized?
Before the introduction of the queue, the service had the annotation @Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) and with each http request the service had a new scope. The same thing is needed, but for each message in the queue.
Answer the question
In order to leave comments, you need to log in
In order for the spring bean to be initialized every time it is requested, it must be marked with an
annotation only once, respectively, in fact it will be a singleton.
And if you ask for such a bean in the ApplicationContext code, then yes, you will always receive a new bean instance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question