Why the Scope type of RabbitTemplate is SCOPE_PROTOTYPE

Why must the Scope type of RabbitTemplate be SCOPE_PROTOTYPE?

Nov.24,2021

does not have to be prototype. RabbitTemplate is thread safe, mainly because channel cannot be shared, but channel is threadlocal in rabbitTemplate source code, so singleton is fine. However, if rabbitTemplate wants to set a callback class, there can only be one callback class if it is singleton, so if you want to set a different callback class, set it to scope of prototype.

Menu