Spouts must implement the ISpout
interface.
The
open
method is called when the spout is initialized and provides the spout with the executing environment.The
close
method is called when the spout is shutdown. There’s no guarantee that this method is called due to how the instance is killed.The
activate
method is called when the spout is asked to back into active state.The
deactivate
method is called when the spout is asked to enter deactive state.The
nextTuple
method is used to fetch tuples from input source and emit it toOutputCollector
.The
ack
method is called when theTuple
with themsgId
emitted by this spout is successfully processed.The
fail
method is called when theTuple
with themsgId
emitted by this spout is not processed successfully.
See TestWordSpout
for a simple spout example.
Instead of implementing the ISpout
interface directly, you can implement IRichSpout
.