public Task Handle(StartReplySaga message, IMessageHandlerContext context) { var sendOptions = new SendOptions(); sendOptions.RouteToThisEndpoint(); sendOptions.DelayDeliveryWith(TimeSpan.FromSeconds(10)); var request = new Request { TheId = message.TheId }; log.Warn("Saga started. Sending Request"); return(context.Send(request, sendOptions)); }
static async Task Main() { //required to prevent possible occurrence of .NET Core issue https://github.com/dotnet/coreclr/issues/12668 Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); var defaultFactory = LogManager.Use <DefaultFactory>(); defaultFactory.Level(LogLevel.Warn); Console.Title = "Samples.RenameSaga.Version1"; var endpointConfiguration = new EndpointConfiguration("Samples.RenameSaga"); SharedConfiguration.Apply(endpointConfiguration); endpointConfiguration.PurgeOnStartup(true); var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); Console.WriteLine("Version1 of Sagas starting. Will exit in 5 seconds. After exist start Phase 2 Endpoint."); #region startSagas var startReplySaga = new StartReplySaga { TheId = Guid.NewGuid() }; await endpointInstance.SendLocal(startReplySaga) .ConfigureAwait(false); var startTimeoutSaga = new StartTimeoutSaga { TheId = Guid.NewGuid() }; await endpointInstance.SendLocal(startTimeoutSaga) .ConfigureAwait(false); #endregion await Task.Delay(TimeSpan.FromSeconds(5)) .ConfigureAwait(false); await endpointInstance.Stop() .ConfigureAwait(false); }
static async Task AsyncMain() { var defaultFactory = LogManager.Use <DefaultFactory>(); defaultFactory.Level(LogLevel.Warn); Console.Title = "Samples.RenameSaga.Version1"; var endpointConfiguration = new EndpointConfiguration("Samples.RenameSaga"); await SharedConfiguration.Apply(endpointConfiguration) .ConfigureAwait(false); endpointConfiguration.PurgeOnStartup(true); var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); Console.WriteLine("Version1 of Sagas starting. Will exit in 5 seconds. After exist start Phase 2 Endpoint."); #region startSagas var startReplySaga = new StartReplySaga { TheId = Guid.NewGuid() }; await endpointInstance.SendLocal(startReplySaga) .ConfigureAwait(false); var startTimeoutSaga = new StartTimeoutSaga { TheId = Guid.NewGuid() }; await endpointInstance.SendLocal(startTimeoutSaga) .ConfigureAwait(false); #endregion await Task.Delay(TimeSpan.FromSeconds(5)) .ConfigureAwait(false); await endpointInstance.Stop() .ConfigureAwait(false); }
public Task Handle(StartReplySaga message, IMessageHandlerContext context) { // throw only for sample purposes throw new Exception("Expected StartReplySaga in MyReplySagaVersion1."); }