2

I have the following SWF Workflow which asynchronously calls 2 activities, gets their results, and passes that to the third activity:

a_future = Future.new.set
b_future = Future.new.set

a_future = activity.send_async(:a_activity, arg1)
b_future = activity.send_async(:b_activity, arg2)

wait_for_all(a_future, b_future)
a_url = a_future.get
b_url = b_future.get

activity.c_activity(arg1, a_url, b_url)

When running this as is, I get the expected return value (which in this case is a URL) in a_url and b_url.

However, when I add retry logic to the activities

activity :a_activity, :b_activity, :c_activity do
  {
    version: "0.0.1",
    default_task_list: $activity_task_list,
    default_task_schedule_to_start_timeout: 30,
    default_task_start_to_close_timeout: 30,
    # ADD the next 3 lines for retry logic
    exponential_retry: {
      maximum_attempts: 5,
    }
  }
end

The value from a_future.get is not a string URL, but is instead:

#<AWS::Flow::Utilities::AddressableFuture:0x007fe87243d908>

I have not been able to figure out how to get the result from that AddressableFuture.

I tried writing some wrapper code that works both with and without retry logic:

def get_return_value(future)
  value = future.get
  if value.kind_of? AWS::Flow::Utilities::AddressableFuture
    value = value.return_value.get
  end

  return value
end

and then:

a_url = get_return_value(a_future)
b_url = get_return_value(b_future)

... but that just goes in circles and still doesn't get the results.

Any ideas on how I can get the return value from both activities, and pass that to the third activity, when the activities have retry logic?

Peter Sankauskas
  • 2,882
  • 4
  • 27
  • 28
  • I guess you have to trigger the future as in triggering a callback. Similar to doing it as in a deferred in Python Twisted. Not sure how to do it in Ruby AWS Simple Workflow though, will give it a shot later. – Rico Apr 16 '14 at 04:19
  • The `wait_for_all` call blocks until both activities are done, so that should be the trigger... no? – Peter Sankauskas Apr 16 '14 at 05:04
  • 1
    It should but I don't see it documented anywhere either. One thing as you may have noticed the code path for when you have an `exponential_retry` parameter configured is different. As you can see here: https://github.com/aws/aws-flow-ruby/blob/master/aws-flow/lib/aws/decider/generic_client.rb . The exponential retry function returns: `Utilities::drill_on_future(future)` and `drill_on _future` returns a future. – Rico Apr 16 '14 at 17:41

0 Answers0