The method IComponent.declareOutputFields(...)
is called on the client machine when the client code calls createTopology()
on the TopologyBuilder instance. Please look at the line 226 in the TopologyBuilder.java where this method gets called on the Spout or Bolt component(s).
The callback method IComponent.declareOutputFields(...)
is part of the topology life cycle rather part of the Spout or Bolt life cycle. To answer your question, this method gets called before open()
method.
The output fields should be declared in the declareOutputFields()
method so that Storm serializes the Spout/Bolt object(s) including the configurations and output fields. The serialized instances of Spout/Bolt are then submitted to the Storm cluster after which the other life cycle methods (activate()
, open()
, etc.) of Spout/Bolt are called.