We know that we can inject custom message converter:
@Bean
MessageConverter messageConverter(){
return new CustomMessageConverter();
}
However in case of ErrorHandler
it doesn't work. Why ? Can I conclude it from code in any way ?
That's true. Spring Boot's RabbitAnnotationDrivenConfiguration
doesn't support that injection.
You have to declare your own SimpleRabbitListenerContainerFactory
@Bean
and supply desired ErrorHandler
injection, as well as all other required options, including MessageConverter
.
Note that overriding out-of-the-box bean you should specify your own one with the rabbitListenerContainerFactory
name to meet condition:
@Bean
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(