Flow Component Lifecycle
When a flow is deployed, each flow component runs through the following phases:
- init
- start
- stop
For each phase a handler can be registered that is executed in the particular phase. All handler source files must be named handler.js.
All operations are performed against the SwiftMQ Stream Interface (SI) or custom library classes. Note that all resources, e.g. memories, inputs, outputs, that are created from the stream
variable are automatically started, stopped and destroyed from the SI so there is usually nothing to do in the start
or stop
phase.
init
During this phase, a flow component creates all resources that it needs during its lifetime. The handler is stored under the init
folder of the flow component:
Example:
function handler() {
stream.create().output(this.props["queuename"]).queue();
}
start
This phase is executed after all components of the flow have successfully passed the init phase. It should be used to start resources. The handler is stored under the start
folder of the flow component:
The components are then active and will receive/send through their connector links.
stop
This phase is executed when a flow stops. The handler is stored under the stop
folder of the flow component: