G
G
grv12018-01-22 12:46:09
Java
grv1, 2018-01-22 12:46:09

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

2 answer(s)
Y
Yerlan Ibraev, 2018-01-22
@mad_nazgul

Uh... can a service be made stateless, not statefull?!

E
Eugene, 2018-01-22
@zolt85

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 question

Ask a Question

731 491 924 answers to any question