Skip to content
neyric edited this page Jan 13, 2013 · 3 revisions

This small tutorial will use the examples in the examples/ directory.

Step1: register all components

First we need to register a domain :

$ swf-register -k domain aws-swf-test-domain

We then register all workflows from examples/:

$ cd examples/
$ swf-register

Finally, we will register all activity types from examples/activities :

$ cd examples/activities
$ swf-register

Step2: run the decider, and the activity poller

Launch a decider Poller:

$ cd examples/
$ swf-decider

Launch an Activity Poller:

$ cd examples/activities
$ swf-activity

Step3: Start the workflow !

$ swf-start hello-workflow "{\"a\":4,\"b\":6}"

Step4: How does this first example works

First, let's have a look at the first decider example :

// step1 -> step2 -> terminate

schedule({
    name: 'step1',
    activity: 'hello-activity'
});


schedule({
    name: 'step2',
    after: 'step1',
    activity: 'echo',
    input: results('step1')
});


stop({
    after: 'step2',
    result: "finished !"
});

What happened ?

  • The hello-workflow is started on SWF through the swf-start command, with the string "{"a":4,"b":6}" as input
  • SWF: schedules a Decision task
  • DECIDER: Receives the decision task. As just_started is true, the step1 is scheduled.
  • SWF: schedules the step1 activity
  • ACTIVITY: Receives the activity task. The echo task will return as "result" what it as been given as input (ie the "{"a":4,"b":6}" string...)
  • SWF: receives step1 results and schedule a decision task
  • DECIDER: receives the decision task. This time, step1 is completed, but step2 is not completed, so step2 is scheduled
  • SWF: schedules the step2 activity
  • ACTIVITY: Receives the activity task. The sum task will decode its input (in JSON format), and return the sum of a and b
  • SWF: receives step2 results and schedule a decision task
  • DECIDER: receives the decision task. step2 is completed so we send a CompleteWorkflowExecution through the stop() function
  • SWF: mark the workflow execution as completed

hello-workflow