Bolts must implement the IBolt
interface.
The
prepare
method is called when the bolt is first initialized and provides the bolt with the executing environment.The
execute
method is called to process a single inputTuple
. TheTuple
contains metadata about component/stream/task it comes from. AndOutputCollector
is used to emit the result.The
cleanup
method is called before the bolt is shutdown. There’s no guarantee that this method is called due to how the instance is killed.
See ExclamationBolt
for a simple bolt example.
Instead of implementing the IBolt
interface directly, you can implement IRichBolt
.