I'm using spring-cloud-starter-stream-rabbit 4.0.2, and want to write my own ErrorHandler for those sending failed messages. Refer to Spring docs, using 'error-handler-definition' property, but it doesn't work, myErrorHandler not invoked, instead Spring's default LoggingHandler been invoked, what's wrong with my settings below?
spring.cloud.stream:
binders:
rabbit:
type: rabbit
environment:
spring.rabbitmq:
publisher-confirms: true
publisher-returns: true
bindings:
output:
error-handler-definition: myErrorHandler
the error handler:
@Bean
public Consumer<ErrorMessage> myErrorHandler() {
return err -> {
log.error("msg:{}", err);
};
}
send msg use StreamBridge:
public class SenderService {
@Autowired
private StreamBridge streamBridge;
public void send(String msg) {
streamBridge.send("output", msg);
}
}