---
title: "[storm]消息事务算法的一个理解"
author: "iwinit"
date: "2013-03-25T20:28:14Z"
tags: ["Storm", "ack"]
categories: ["操作系统"]
slug: "storm"
draft: false
lastmod: "2013-03-26T09:34:56Z"
id: 1836380
url: "https://iwinit.iteye.com/blog/1836380"
---

https://github.com/nathanmarz/storm/wiki/Guaranteeing-message-processing这篇文章介绍了storm如何处理消息事务，提到了用一个ack value代表一个tuple的生命周期。

其算法是“It is simply the xor of all tuple ids that have been created and/or acked in the tree.”

如果topology是

```
 Spout->A->B
```

 ，那么计算过程应该是

```
(0^U(s))^(U(s)^U(A))^(U(A)^0)=0
```

U(s)代表spout创建的tuple id.也就是tuple创建时和ack时都要XOR一次，当所有component都处理完时，结果值是0.最后一个bolt没有下游bolt时为0.