2 つのアクティビティを非同期的に呼び出し、その結果を取得し、それを 3 番目のアクティビティに渡す次の SWF ワークフローがあります。
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)
これをそのまま実行すると、予想される戻り値 (この場合は URL) がa_url
とで取得されますb_url
。
ただし、アクティビティに再試行ロジックを追加すると
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
from の値a_future.get
は文字列 URL ではなく、次のとおりです。
#<AWS::Flow::Utilities::AddressableFuture:0x007fe87243d908>
それから結果を得る方法を理解できませんでしたAddressableFuture
。
再試行ロジックの有無にかかわらず機能するラッパー コードをいくつか書いてみました。
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
その後:
a_url = get_return_value(a_future)
b_url = get_return_value(b_future)
...しかし、それはぐるぐる回るだけで、まだ結果が得られません。
アクティビティに再試行ロジックがある場合、両方のアクティビティから戻り値を取得し、それを 3 番目のアクティビティに渡す方法についてのアイデアはありますか?