问题
Is there an option to limit the number of replays when using anchoring? I have a tuple that should parse json object, in case it gets an exception I prefer it will replay two more times.
I tried to track the number of times storm is replaying with prints, but each time I entered non parse-able value the counter showed different result.
catch{
collector.fail(tuple)
}
回答1:
The fail
method in the BaseRichSpout
class is empty . meaning you are supposed to override the same method to handle the failed tuple reply strategy.
回答2:
Add a field to the tuple to hold the number of times to try again and use the tuple as both id and object on the spout's emit. When the tuple fails, the spout gets the key (which is the tuple with the number of remaining retries) back and you can conditionally re-emit the tuple with the retry count decremented.
来源:https://stackoverflow.com/questions/25864052/storm-is-it-possible-to-limit-the-number-of-replays-on-fail-anchoring