static async Task AsyncMain() { Console.Title = "Samples.Notifications"; #region logging DefaultFactory defaultFactory = LogManager.Use <DefaultFactory>(); defaultFactory.Level(LogLevel.Fatal); #endregion #region endpointConfig EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.Notifications"); SubscribeToNotifications.Subscribe(endpointConfiguration); #endregion endpointConfiguration.SendFailedMessagesTo("error"); endpointConfiguration.UseSerialization <JsonSerializer>(); endpointConfiguration.EnableInstallers(); endpointConfiguration.UsePersistence <InMemoryPersistence>(); IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration); try { await endpoint.SendLocal(new MyMessage()); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } finally { await endpoint.Stop(); } }
static async Task AsyncMain() { Console.Title = "Samples.Notifications"; #region logging var defaultFactory = LogManager.Use <DefaultFactory>(); defaultFactory.Level(LogLevel.Fatal); #endregion #region endpointConfig var endpointConfiguration = new EndpointConfiguration("Samples.Notifications"); SubscribeToNotifications.Subscribe(endpointConfiguration); #endregion endpointConfiguration.SendFailedMessagesTo("error"); endpointConfiguration.UseSerialization <JsonSerializer>(); endpointConfiguration.EnableInstallers(); endpointConfiguration.UsePersistence <InMemoryPersistence>(); #region customDelayedRetries var recoverability = endpointConfiguration.Recoverability(); recoverability.Delayed( customizations: delayed => { delayed.TimeIncrease(TimeSpan.FromSeconds(1)); }); #endregion var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); try { var message = new MyMessage { Property = "PropertyValue" }; await endpointInstance.SendLocal(message) .ConfigureAwait(false); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } finally { await endpointInstance.Stop() .ConfigureAwait(false); } }
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"); Console.Title = "Samples.Notifications"; #region logging var defaultFactory = LogManager.Use <DefaultFactory>(); defaultFactory.Level(LogLevel.Fatal); #endregion #region endpointConfig var endpointConfiguration = new EndpointConfiguration("Samples.Notifications"); SubscribeToNotifications.Subscribe(endpointConfiguration); #endregion endpointConfiguration.UsePersistence <LearningPersistence>(); endpointConfiguration.UseTransport <LearningTransport>(); #region customDelayedRetries var recoverability = endpointConfiguration.Recoverability(); recoverability.Delayed( customizations: delayed => { delayed.TimeIncrease(TimeSpan.FromSeconds(1)); }); #endregion var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); var message = new MyMessage { Property = "PropertyValue" }; await endpointInstance.SendLocal(message) .ConfigureAwait(false); Console.WriteLine("Press any key to exit"); Console.ReadKey(); await endpointInstance.Stop() .ConfigureAwait(false); }
static async Task Main() { Console.Title = "Samples.Notifications"; #region logging var defaultFactory = LogManager.Use <DefaultFactory>(); defaultFactory.Level(LogLevel.Fatal); #endregion #region endpointConfig var endpointConfiguration = new EndpointConfiguration("Samples.Notifications"); SubscribeToNotifications.Subscribe(endpointConfiguration); #endregion endpointConfiguration.UsePersistence <LearningPersistence>(); endpointConfiguration.UseTransport <LearningTransport>(); #region customDelayedRetries var recoverability = endpointConfiguration.Recoverability(); recoverability.Delayed( customizations: delayed => { delayed.TimeIncrease(TimeSpan.FromSeconds(1)); }); #endregion var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); var message = new MyMessage { Property = "PropertyValue" }; await endpointInstance.SendLocal(message) .ConfigureAwait(false); Console.WriteLine("Press any key to exit"); Console.ReadKey(); await endpointInstance.Stop() .ConfigureAwait(false); }