Let's first take a look at the spout in the topology. In contrast to Storm, Trident introduces the concept of batches. Unlike Storm spouts, Trident spouts must emit tuples in batches.
Each batch is given its own unique transaction identifier. A spout determines the composition of a batch based on the constraints of its contract. There are three types of contracts for spouts: Non-transactional, Transactional, and Opaque.
Non-transactional spouts provide no guarantee on the composition of the batches and might overlap. Two different batches might contain the same tuples. Transactional spouts guarantee that batches are non-overlapping and that the same batch always contains the same tuples. Opaque spouts guarantee that batches are non-overlapping, but the contents of a batch may change.
This is depicted in the following table:
Spout type |
Batches may overlap |
Batch contents may change |
---|---|---|
Non-transactional |
X |
X |
Opaque |
X | |
Transactional |