Bolts must implement the IBolt interface.
public interface IBolt extends Serializable {
void prepare(Map<String, Object> heronConf, TopologyContext context, OutputCollector collector);
void execute(Tuple input);
void cleanup();
}
The
preparemethod is called when the bolt is first initialized and provides the bolt with the executing environment.The
executemethod is called to process a single inputTuple. TheTuplecontains metadata about component/stream/task it comes from. AndOutputCollectoris used to emit the result.The
cleanupmethod 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.