I use "spring-cloud-azure-stream-binder-eventhubs" for event hubs development. Now when I deal with consumers, there may be some business exceptions.
my config
stream:
function:
definition: consumer
bindings:
consumer-in-0:
destination: test-eventhub
group: $Default
consumer:
max-attempts: 3
supply-out-0:
destination: test-eventhub
my consumer
@Bean
public Consumer<Message<String>> consumer() {
return message -> {
if (message.equals("a")) {
throw new RuntimeException("run time exception");
}
};
my global exception handler
@ServiceActivator(inputChannel = "errorChannel")
public void globalConsumerError(Message<?> message) {
MessageHandlingException messageHandlingException = (MessageHandlingException) message.getPayload();
log.info("message : {}", new String((byte[]) messageHandlingException.getFailedMessage().getPayload()));
log.error("error info: {}", message);
// do something
}
I hope that if an exception occurs, it can start retrying by setting max-attempts. But it didn't work, please help me with my doubts, thanks