예제 #1
0
        protected override async Task <RESTActivity> GetScheduledActivityAsync(string orchestrationId)
        {
            RESTActivity activity = null;

            var activityTaskRequest = new PollForActivityTaskRequest
            {
                Domain   = Constants.LAMBDA_BIZ_DOMAIN,
                Identity = Guid.NewGuid().ToString(),
                TaskList = new TaskList
                {
                    Name = Constants.LAMBDA_BIZ_TASK_LIST + orchestrationId
                }
            };

            var activityTaskResponse = await _amazonSimpleWorkflowClient.PollForActivityTaskAsync(activityTaskRequest);

            if (activityTaskResponse.ActivityTask.TaskToken != null)
            {
                activity = new RESTActivity
                {
                    TaskToken  = activityTaskResponse.ActivityTask.TaskToken,
                    RESTConfig = JsonConvert.DeserializeObject <RESTConfig>(activityTaskResponse.ActivityTask.Input)
                };
            }

            return(activity);
        }
예제 #2
0
 public void Worker(string tasklistName)
 {
     while (true)
     {
         Console.WriteLine("Starting Worker" + tasklistName + ": Polling for activity...");
         PollForActivityTaskRequest pollForActivityTaskRequest =
             new PollForActivityTaskRequest()
         {
             Domain   = domainName,
             TaskList = new TaskList()
             {
                 Name = tasklistName
             }
         };
         PollForActivityTaskResponse pollForActivityTaskResponse = swfClient.PollForActivityTaskAsync(pollForActivityTaskRequest).Result;
         Console.WriteLine("finished polling pollForActivityTaskResponse");
         RespondActivityTaskCompletedRequest respondActivityTaskCompletedRequest =
             //Ideally this function would actually do something and return real values. But since it's just hello
             //world we're returning nothing of value. (a static string)
             new RespondActivityTaskCompletedRequest()
         {
             Result    = "{\"customReturnValue\":\"CustomReturnResult\"}",
             TaskToken = pollForActivityTaskResponse.ActivityTask.TaskToken
         };
         if (pollForActivityTaskResponse.ActivityTask.ActivityId == null)
         {
             Console.WriteLine("Starting Worker" + tasklistName + ": NULL");
         }
         else
         {
             RespondActivityTaskCompletedResponse respondActivityTaskCompletedResponse =
                 swfClient.RespondActivityTaskCompletedAsync(respondActivityTaskCompletedRequest).Result;
             Console.WriteLine("Starting Worker" + tasklistName + ": Activity completed" + pollForActivityTaskResponse.ActivityTask.ActivityId);
         }
     }
 }