当我编写风暴拓扑时,我发现元组的顺序并不总是与喷口发出的顺序相同。(喷口的功能是在线读取文件并将线发送到螺栓< strong>没有 Thread.sleep()
,所以这个程序会非常快。)
有谁能告诉我如何确保喷嘴或螺栓发出的元组顺序?非常感谢!
答案 0 :(得分:3)
您可能需要查看Trident topology
Trident solves this problem by doing two things:
Each batch is given a unique id called the "transaction id". If a batch is retried it will have the exact same transaction id.
State updates are ordered among batches. That is, the state updates for batch 3 won't be applied until the state updates for batch 2 have succeeded.