Comments (4)
Retry middleware is meant for temporary issues, like some network error while saving to database or an error from an external service. In most cases the Pub/Sub itself will re-deliver the message as it won’t be acked, but using middleware gives you a bit more control.
PRs are welcome, of course! 🙂 I’d consider making this a separate middleware, something like DiscardOnError
. Possibly could also allow users to take some action before, like log the message. Although in most cases you’d probably want to use PoisonQueue anyway, as it might be hard to distinguish between temporary retryable errors and non-fixable errors.
Also, there’s a common pattern of using both of them in a chain: first, you try to retry the message for several times, and if that doesn’t work that probably means the issue is with message format or other serious error. So PoisonQueue catches it and stores on a separate topic. This is as simple, as adding both middlewares one after another (PoisonQueue first).
from watermill.
Hey @smazurov.
The exit from Retry
middleware, when the handler returns no error is this line:
The line you mentioned will return the error after several retries, when break
happens out of the loop.
The change you proposed would make the middleware return no error after several attempts of retry. This would make you lose the message (because it would be acked). If that's the behaviour you're looking for, take a look at PoisonQueue
middleware: https://watermill.io/docs/middlewares/#poison
Does that make sense?
from watermill.
That makes sense, for my own education, whats the point of retry middleware? I guess the assumption is that one handler could be faulty while another handler can handle that message? Ideally what I'm looking for is errors that I know won't ever be resolved for that message (say extra validation), so I want to just get rid of it. PoisonQueue should work, so thanks for that!
Alternatively, would you be open to accepting a PR that adds an option to drop failed messages?
from watermill.
Hello @smazurov, is everything clear now?
I'm closing the issue but if it shouldn't please let me know :)
from watermill.
Related Issues (20)
- PGX Subscriber InvalidIfaceAssign HOT 1
- Log with fields on error in router HOT 3
- s
- MaxOutstandingMessages doesn't seem to be working
- follow-up handler will be broke while before msg handler error, what is the best practice for this situation?
- `msg.Nack` causes infinite loop with gochannel pubsub HOT 4
- Publish message processing delay in metrics Middleware?
- How to subscribe to all gochannel ? HOT 2
- Any plans to add support of RabbitMQ Streaming?
- Generated topic names for PubSub tests does not conform with Azure guidelines
- How to delete message after ack? HOT 1
- Context not being propagated through command bus HOT 2
- Is it possible to get google pubsub server generated unique message-id? HOT 3
- Data race on Publish for Google pubsub
- SQLite driver HOT 4
- Log custom fields inside message router
- Invalid publisher name in metrics
- Resume after shutdown always fetch last interrupted message again
- How to process a batch of received messages instead of a single piece?
- Can you output the message metadata to the logs?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from watermill.