Netflix / glisten

Ease of use Groovy library for building JVM applications with Amazon Simple Workflow (SWF)
Apache License 2.0
66 stars 31 forks source link

Getting started? #25

Open xnickmx opened 10 years ago

xnickmx commented 10 years ago

I would like to actually run the example workflow (not just the unit tests), but I haven't been able to get it to work. While I use several other AWS products I have never run any SWF workflow successfully before, so I am guessing there is some basic setup I haven't completed. Can you help me bridge the gap?

Here's what I tried:

At first it fails because the domain and workflow type aren't in SWF. So, I manually added them using the AWS console. After that, the code runs, but it doesn't seem to do anything. Looking in the AWS console, it seems that the workflow has timed out. In addition, it seems like the local Java code, BayAreaTripWorkflowImpl and BayAreaTripActivitiesImpl, is never called.

Any ideas?

Any chance you could add a simple integration test to the existing code base that would allow for running the workflow for real, instead of just in a unit test?

claymccoy commented 10 years ago

Thanks for your feedback. I could add such an integration test. It is a little tricky getting it the credentials that it needs. Maybe not if I don't run it in the public build. We always point people to Asgard as the "integration test". :) So you started your workflow, and all of that looks great. I can tell that you have done some research. It is going to time out because there is no decider to figure out what to do next. If there was then it would decide to schedule an activity. It would then timeout because nothing is polling for activity tasks. So you need to poll of decision tasks and activity tasks, and you can do this with the SWF WorkflowWorker and ActivityWorker respectively. Check out how we bootstrap all of this in Asgard FlowService.afterPropertiesSet(). https://github.com/Netflix/asgard/blob/master/grails-app/services/com/netflix/asgard/FlowService.groovy#L65

claymccoy commented 10 years ago

BTW, the task pollers don't have to even be in the same application, but that is just how we do it in Asgard at the moment.

xnickmx commented 10 years ago

Hi Clay, thanks for the pointers on WorkflowWorker and ActivityWorker. That with the Asgard code was enough for me to figure it out. I created an integration test that works and sent it to you as a Pull Request. It looks like I sent it way prematurely though: it breaks the build. It was already automatically rejected by your CI server. As I mentioned earlier, I am not a Gradle expert. Hopefully the fix is straightforward.

A few more thoughts -- (note these are numbered 1, 2, 3 in the editor, but GitHub is unhelpfully displaying them as 1, 1 and 1 again)

  1. I think it makes sense for this example to be in its own project/Git repo. It really doesn't make sense for the example workflow to be distributed with the rest of the Glisten library. In addition, if you made a separate example project, then you could really show how it is used with nice examples, full end-to-end running workflows, etc.
  2. Although I thought I was able to run this code multiple times before, now it is complaining with this error:

com.amazonaws.services.simpleworkflow.model.TypeAlreadyExistsException: Status Code: 400, AWS Service: AmazonSimpleWorkflow, AWS Request ID: 83b49589-afdd-11e3-bb7a-1f04d5203743, AWS Error Code: TypeAlreadyExistsFault, AWS Error Message: WorkflowType=[name=BayAreaTripWorkflow.start, version=1.0]

I'm not really sure what I can do, other than change the version number of the workflow, which doesn't seem like something I should have to do. Any ideas?

  1. How are you supposed to access the status messages? It's nice that BayAreaTripWorkflowImpl logs status messages, but I didn't see a good way to access them. In the integration test, that code doesn't ever create a BayAreaTripWorkflowImpl object itself. Would I use SwfWorkflowOperations.of(BayAreaTripActivities).logHistory ? I'm not sure if this is the "right" way to access these messages. I was thinking it would be nice to actually print these out somewhere in the test so that I would have some idea about what was running.

Anyway, I still feel like there is quite a bit I don't understand. I would love to learn more.

xnickmx commented 10 years ago

I created a little example program that runs the BayAreaWorkflow example: https://github.com/xnickmx/GlistenRunnableExample

I am planning on improving it in the future. I could use your help to figure out how to:

  1. programmatically determine if the workflow is complete
  2. programmatically retrieve events and activities
  3. gracefully shutdown all workers

Thanks!

dashfwd commented 10 years ago

Would it be possible to do a simple Grails project that does the "Hello World" example or the bay area example? I'm struggling with getting this running.

xnickmx commented 10 years ago

@dashfwd was this message for me?

I could do a Grails project, but I thought that a one-class console app would be simpler.

BTW, I added the improvements mentioned in my comment from a couple of days ago.

claymccoy commented 10 years ago

I could make a small example Grails project rather than always pointing to Asgard's use of SWF and Glisten.

dashfwd commented 10 years ago

That would be immensely helpful, thanks!