Search code examples
javaspringspring-amqpspring-rabbit

Spring RabbitTemplate execute method visibility


RabbitTemplate has an execute method that is public, and another one that receives a ConnectionFactory but it is private. I could understand that it is private if ConnectionFactory was not exposed, but it already has a getConnectionFactory() method.

I would like to decorate execute method behavior but cannot. Is there a reason I am not seeing for not making it protected so we can override it?


Solution

  • Can you edit the question to explain exactly what you want to achieve?

    I am not keen on exposing it because there would be nothing to stop a user from calling it with a completely unrelated connection factory (no guarantee that it was received from getConnectionFactory()).

    While I wouldn't expect any problems with that, there might be some unintended side effects, particularly if the template is transactional, which could cause us some support pain when something weird happens.

    Perhaps we can come up with some other way to get you what you need.