简体   繁体   中英

Spring Cloud Kinesis Binder How to Handle ERROR for Producer and Consumer - As per Documentation it is Not working

I have followed the below documentation and I have a producer and Consumer working perfectly fine with Kinesis Stream. I would like to understand how to handle the ERROR in Producer (Source) and Consumer (Processor) in case of any exception happens.

I have tried below approaches as per Spring Stream Error Handling Documentations:

  1. I have tried using @ServiceActivator("input-stream.input-stream-group.erros") - this works, but my "input-stream" is a dynamic name in each production environment as per the policy I should append a production environment name while defining the Data Stream. This is preferred way but How to solve this?

  2. I have tried using @ServiceActivator("errorChannel") - this is not working means the ERROR is catching and printing if I introduce a method for this and put a Logger but ERROR is throwing due to below rethrow in org.springframework.cloud.stream.binding.StreamListenerMessageHandler (line 53-68)

     catch (Exception e) { if (e instanceof MessagingException) { throw (MessagingException) e; } else { throw new MessagingException(requestMessage, "Exception thrown while invoking " + this.invocableHandlerMethod.getShortLogMessage(), e); } }
  3. I have Autowired a MessageChannel in the same name of "errorChannel" and while Catching the Exception I have prepared a Message and send to it, but same as above in the ServiceActivator method behaves.

How do I can handle and solve this? Please suggest and help me.

Documentation: https://github.com/spring-cloud/spring-cloud-stream-binder-aws-kinesis/blob/master/spring-cloud-stream-binder-kinesis-docs/src/main/asciidoc/overview.adoc#error-channels

Just for the benefit of all who are facing the issue. If you miss the comment section. The answer from Deepak Chaudhary is working fine for the Consumer.

Please checkout stackoverflow.com/questions/63270755/…, if it helps. Thank you. – Deepak Chaudhary

Thank you Deepak

would like to understand how can we do this for producer.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM