Question

I have started learning amazon web services with simple workflow service. I have completed the eclipse setup for development and successfully completed the hello world workflow application from here.

For using the same application on web platform, I tried creating AWS web project and calling the workflow methods from servlet. The servlet runs without any error and output is printed to console. If I want the workflow to return the string message which is printed on console, what changes are needed?

Was it helpful?

Solution

Same question posted at amazon aws forums . Their is no clear documentation on AWS Simple Workflow Framework. You can check here

AWS Workflow executes Asynchronously so that why generated code return type is void. IF you want then you can get by using

GetWorkflowExecutionHistoryRequest historyRequest = new GetWorkflowExecutionHistoryRequest();
historyRequest.setDomain(domain);
historyRequest.setExecution(workflowExecution);
historyRequest.setReverseOrder(true);
History workflowExecutionHistory = service.getWorkflowExecutionHistory(historyRequest);

If you want result then Just create a thread and when result populates in method you will get data . But this is not good way to run thread continuously.

OTHER TIPS

The step that you need to do to return a value from a workflow are:

  • have the workflow declare that it's return value is a Promise containing the type that you want to return.
  • have the workflow return a Promise (or a Settable) with the value that you want to return.
  • have the client check if the workflow is closed and complete using the DescribeWorkflowExecutionRequest API
  • have the client get the result from the workflow history using the GetWorkflowExecutionHistoryRequest API
  • use the workflow's DataConverter to deserialize the result into the result object that you want.

Below is an example of all of those changes applied to the HelloWorld example provided by AWS. The HelloWorld example below returns a value from the workflow and prints the value in the client.

https://github.com/aquesnel/aws-sdk-java/commit/87a80b5946f02283faecaa7436828ecd1c43921c

What is your use case? Workflow returning a value is usually a bad idea (unless it is a child workflow) as workflow is asynchronous and long running. Console application that started it should be able to exit without affecting workflow execution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top