Storm: Is it possible to limit the number of replays on fail (Anchoring)?

匆匆过客 提交于 2019-12-08 10:05:35

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!