Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Once a flow has been started via the start() method it can take an arbitrarily long time to complete; you can see if the flow has completed via the
isStopped() method. You can explicitly complete a flow using the stop() method whenever you like; typically when you are responding to state changes.

A flow could fail for some reason (such as it timed out or some error occurred) so there is a method isFailed() which can be used to easily inspect the flow. Rather like the stop() method, you can call fail(reason) if you wish to terminate a flow with the flow marked as the Failed rather than Stopped state.

Using timeouts

Its very common to add timeouts onto flows so that if the flow is not complete by a certain time then the flow is stopped & failed; often another parent
flow may then do something differently if one of its child flows fails.

There is a useful base flow called TimeoutFlow which you can derive from to make your own flow which can be started/stopped/failed and which can be timed out.

You can explicitly register the flow with a timer and call the onTimedOut() method yourself or just call the startWithTimeout() method to start the flow registering the timeout.

Composing flows

One of the main reasons for using an object orientated language is to make composition and reuse possible; similarly BeanFlow allows you to compose flows together to make modular and reusable workflow constructs easily.