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(
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.