Amazon AWS Simple Workflow Service SWF C # Sample

I was wondering if there is any sample C # code for the SWF workflow for the AWS.NET SDK?

AWS forum post: https://forums.aws.amazon.com/thread.jspa?threadID=122216&tstart=0

+4
source share
2 answers

As part of my introduction to SWF, I ended up writing a regular library of applications that I hope others can use. It is called SimpleWorkflowFramework.NET and is available as open source at https://github.com/sdebnath/SimpleWorkflowFramework.NET . He could definitely use a lot of help, so if you're interested, jump straight ahead! :)

+4
source

I developed the open source .NET library - Guflow for programming Amazon SWF. Here's how you can write a workflow to transcode a video:

[WorkflowDescription("1.0")] public class TranscodeWorkflow : Workflow { public TranscodeWorkflow() { //DownloadActivity is the startup activity and will be scheduled when workflow is started. ScheduleActivity<DownloadActivity>().OnFailure(Reschedule); //After DownloadActivity is completed TranscodeActivity activity will be scheduled. ScheduleActivity<TranscodeActivity>().AfterActivity<DownloadActivity>() .WithInput(a => new {InputFile = ParentResult(a).DownloadedFile, Format = "MP4"}) ScheduleActivity<UploadToS3Activity>().AfterActivity<TranscodeActivity>() .WithInput(a => new {InputFile = ParentResult(a).TranscodedFile}); ScheduleActivity<SendConfirmationActivity>().AfterActivity<UploadToS3Activity>(); } private static dynamic ParentResult(IActivityItem a) => a.ParentActivity().Result(); } 

In the example above, for clarity, I did not route the task. Here's how you can create activity:

 [ActivityDescription("1.0")] public class DownloadActivity : Activity { //It supports both sync/async method. [ActivityMethod] public async Task<Response> Execute(string input) { //simulate downloading of file await Task.Delay(10); return new Response() { DownloadedFile = "downloaded path", PollingQueue = PollingQueue.Download}; } public class Response { public string DownloadedFile; } } 

For clarity, I leave examples of other actions. Guflow supported documentation , tutorial and samples .

0
source

All Articles