Closed
Description
Describe the issue
When the producer error channel is enabled and an error-handler-definition
is defined for that binding, the error handler doesn't receive any error messages.
To Reproduce
Steps to reproduce the behavior:
- Create a error handler function like:
@Bean public Consumer<ErrorMessage> myErrorHandlerFnc() { msg -> logger.info("failed to publish message {}", msg); }
- Configure any output binding as follows:
spring.cloud.stream.bindings.<binding-name>.producer.error-channel-enabled=true spring.cloud.stream.bindings.<binding-name>.error-handler-definition=myErrorHandlerFnc
- Cause the producer binding to throw an exception
- Notice that
myErrorHandlerFnc
doesn't receive the error message.
Version of the framework
Spring Boot: 3.3.2
Spring Cloud: 2023.0.3
Expected behavior
myErrorHandlerFnc
to receive error messages from the producer binding.
Additional context
Looking at AbstractMessageChannelBinder.registerErrorInfrastructure(
ProducerDestination destination, String bindingName), it seems like subscribeFunctionErrorHandler()
needs to be called there against the producer binding's error channel.