simpler_workflow icon indicating copy to clipboard operation
simpler_workflow copied to clipboard

How to get last activity name?

Open davidpelaez opened this issue 12 years ago • 1 comments

Hi,

I have an on_activity_completed do |task, event| but I don't know how to find the name of the task that just completed. Your gem is by far the cleaneast and easiest SWF solution to use. The recently released aws-flow is so complicated and messy. But I'm stuck and I can't figure out how to write logic in the decider based on what task completed.

Thanks for your work, it's very helpful to have it available.

PS: If there's a better place to put this question please let me knkow.

davidpelaez avatar Sep 09 '13 06:09 davidpelaez

Here's how I normally do it:

  decision = register_workflow("hello-world", "1.0.1") do
    initial_activity :hello, "1.0.0"

    on_activity_completed do |task, event|
      completed_event = scheduled_event(task, event)
      case completed_event.attributes.activity_type.name
      when "hello"
        task.schedule_activity_task record.to_activity_type, :input => event.attributes.result
      when "record"
        task.complete_workflow_execution :result => 'success'
      end
    end
  end

(from fredjean/swf_example )

Let me know if this helps....

Would it be a good idea to add a method that makes it easier to pull out?

fredjean avatar Sep 09 '13 17:09 fredjean