From ce8a6d3a0a00c4cc480bba8bc46216c0bcaa812a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loren=20=F0=9F=A4=93?= Date: Fri, 29 Mar 2024 23:52:48 -0400 Subject: [PATCH] exit code 137 --- src/SignalsQueries/LoyaltyProgram.workflow.cs | 2 +- src/SignalsQueries/MyActivities.cs | 1 + src/SignalsQueries/Program.cs | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SignalsQueries/LoyaltyProgram.workflow.cs b/src/SignalsQueries/LoyaltyProgram.workflow.cs index 858a46a..a01a142 100644 --- a/src/SignalsQueries/LoyaltyProgram.workflow.cs +++ b/src/SignalsQueries/LoyaltyProgram.workflow.cs @@ -28,10 +28,10 @@ public async Task NotifyPurchaseAsync(int purchaseTotalCents) if (Points >= 10_000) { + Points -= 10_000; await Workflow.ExecuteActivityAsync( () => MyActivities.SendCoupon(userId), new() { ScheduleToCloseTimeout = TimeSpan.FromMinutes(5) }); - Points -= 10_000; } } } \ No newline at end of file diff --git a/src/SignalsQueries/MyActivities.cs b/src/SignalsQueries/MyActivities.cs index 1e24cf5..25c70f8 100644 --- a/src/SignalsQueries/MyActivities.cs +++ b/src/SignalsQueries/MyActivities.cs @@ -1,5 +1,6 @@ namespace TemporalioSamples.SignalsQueries; +using Microsoft.Extensions.Logging; using Temporalio.Activities; public class MyActivities diff --git a/src/SignalsQueries/Program.cs b/src/SignalsQueries/Program.cs index 1746531..afa948d 100644 --- a/src/SignalsQueries/Program.cs +++ b/src/SignalsQueries/Program.cs @@ -41,6 +41,9 @@ async Task RunWorkerAsync() async Task ExecuteWorkflowAsync() { + // If the workflow is already running from a previous run, terminate it + await client.GetWorkflowHandle("signals-queries-workflow-id").TerminateAsync(); + Console.WriteLine("Executing workflow"); var handle = await client.StartWorkflowAsync( (LoyaltyProgram wf) => wf.RunAsync("user-id-123"), @@ -52,7 +55,7 @@ async Task ExecuteWorkflowAsync() await handle.SignalAsync(wf => wf.NotifyPurchaseAsync(3_000)); var points = await handle.QueryAsync(wf => wf.Points); - Console.WriteLine("Remaining points: {Points}", points); + Console.WriteLine("Remaining points: {0}", points); } switch (args.ElementAtOrDefault(0))