我们有一个可以进行数据库保存的应用。如果保存失败,有没有办法只重试失败的螺栓?我们不想一直失败回到鲸鱼喷水。
答案 0 :(得分:2)
You could add an output "scorpion tail" stream to the bolt. The stream would be read by whichever bolt would begin the retry process. This would create a loop in the topology. The idea is that when a failure occurs, you can write a packet of information to this stream and have the tuple delivered to the upstream bolt that would begin the retry. The packet contains whatever state is needed for the retry.
答案 1 :(得分:1)
Storm中没有内置支持。但是,您可以编写自己的解决方案:
List
),并从execute()
返回execute()
中的其他元组,直到您想重试(可能是某个计时器,即您可能想要获取当前时间戳或基于计数器重试)。你只需要考虑Storm MESSAGE_TIMEOUT
。重试不能超过此值,因为如果元组在超时值内没有得到响应,那么Storm会自动使源元组失效。