spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

Propagate async publisher Pub/Sub errors into Stream error channel #2501

Open elefeint opened 4 years ago

elefeint commented 4 years ago

Per Spring Cloud Stream errorChannelEnabled docs,

if the binder supports asynchroous send results, send failures are sent to an error channel for the destination.

We don't use the errorChannel parameter when creating producer message handler at all right now.

I've clarified the title that this relates to the Publisher errors.

dinvlad commented 2 years ago

Has this been addressed? In other words, could one add errorChannel handler that will be invoked instead of nacking messages? Thanks

elefeint commented 2 years ago

This was done for the subscription side (for a Spring Cloud Stream sink), but not for publishing side (for a Spring Cloud Stream source).

Which one is your usecase?

dinvlad commented 2 years ago

Thanks @elefeint , I've tried this but with a global errorChannel instead and it isn't working for me, for some reason.

elefeint commented 2 years ago

@dinvlad Replacing this line with @ServiceActivator(inputChannel = "errorChannel") captures the error for me. There are two things that could be tripping you up: 1) Spring Cloud Stream won't consider an error handed off to the global error handler "handled", and will propagate an error back to the binder. 2) If a stream-specific my-topic.my-group.errors has a listener, there is no longer an error to propagate to the global channel; the process completes successfully.

In the future, please create a new issue with any relevant information about what you tried and what the expected outcome was -- this makes it easier for developers to find useful threads in the future.

dinvlad commented 2 years ago

OK, thanks for clarifying @elefeint - I was under the impression I could get a global "catch all", but looks like that's not how it works. I'm assuming this behavior is not specific to PubSub?

elefeint commented 2 years ago

Right; this is how Spring Cloud Stream works -- here is a relevant SO explanation.