Skip to content

swf activity command

neyric edited this page Dec 31, 2012 · 1 revision

swf-activity

Start an activity-poller for AWS SWF.

Usage: swf-activity

Options:
    -f, --file      file to execute in a node spawed process  [default: "/Users/neyric/git/aws-swf/cli/activity-worker.js"]
    -d, --domain    SWF domain                                [default: "aws-swf-test-domain"]
    -t, --tasklist  tasklist                                  [default: "aws-swf-tasklist"]
    -i, --identity  identity of the poller                    [default: "ActivityPoller-hostname-PID"]
    -h, --help      show this help                          
    -c, --fetchconfigfile  js file which exports the fetch_config method  [default: "/Users/neyric/git/aws-swf/cli/fetch_config_file.js"]
    --accessKeyId          AWS accessKeyId                              
    --secretAccessKey      AWS secretAccessKey 

Examples :

# Start an activity poller for all activity modules in the working directory
$ cd examples/activities
$ swf-activity

# Same thing but on a different domain & taskList
$ cd examples/activities
$ swf-activity -t server-A-taskList -d my-domain-name

How it works

What does swf-activity do :

  • Creates an ActivityPoller, which polls SWF for new activity tasks
  • For each new activity task received, spawns a node process (specified by -f), passing the activity task as an argument in JSON.
  • The default process file (activity-worker.js), will use the 'fetchconfigfile' to retreive the global configuration for this activity (such as credentials). The default fetchconfigfile will look for a file named config.json in the activity directory.
  • Then, it will look for a node.js module in the current working directory with the same name as the activity type, and call worker(task, config)
  • When the spawed process exits, polls for new activity tasks

What does swf-activity doesn't do :

  • The main poller process doesn't send any result to SWF. It is up to the worker module to send the response ! ( task.respondCompleted or respondFailed )

Check out the aws-swf-activities project which provides some common activity workers such as :

  • making an HTTP request
  • sending an email
  • making a SOAP request
  • making an XMLRPC request
  • etc...