static async Task AsyncMain() { BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.WcfCallbacks"); busConfiguration.UseSerialization <JsonSerializer>(); busConfiguration.UsePersistence <InMemoryPersistence>(); busConfiguration.EnableInstallers(); busConfiguration.SendFailedMessagesTo("error"); #region startbus IEndpointInstance endpoint = await Endpoint.Start(busConfiguration); try { IBusSession busSession = endpoint.CreateBusSession(); using (StartWcfHost(busSession)) { Console.WriteLine("Press any key to exit"); Console.ReadKey(); } } finally { await endpoint.Stop(); } #endregion }
public async Task InjectEndpoint() { #region Hosting-Inject ContainerBuilder containerBuilder = new ContainerBuilder(); BusConfiguration busConfiguration = new BusConfiguration(); IEndpointInstance endpointInstance = await Endpoint.Start(busConfiguration); containerBuilder.Register(_ => endpointInstance.CreateBusSession()).InstancePerDependency(); #endregion }
async Task StartBus() { BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.Callbacks.WebSender"); busConfiguration.UseSerialization<JsonSerializer>(); busConfiguration.UsePersistence<InMemoryPersistence>(); busConfiguration.EnableInstallers(); busConfiguration.SendFailedMessagesTo("error"); Endpoint = await NServiceBus.Endpoint.Start(busConfiguration); BusSession = Endpoint.CreateBusSession(); }
async Task Send() { var busConfiguration = new BusConfiguration(); #region BasicSend IEndpointInstance instance = await Endpoint.Start(busConfiguration); IBusSession busSession = instance.CreateBusSession(); await busSession.Send(new MyMessage()); #endregion }
public async Task Publish() { #region publishAtStartup BusConfiguration busConfiguration = new BusConfiguration(); //Other config IEndpointInstance endpointInstance = await Endpoint.Start(busConfiguration); IBusSession busSession = endpointInstance.CreateBusSession(); await busSession.Publish(new MyEvent()); #endregion }
public void ScheduleTask() { IEndpointInstance endpointInstance = null; #region ScheduleTask // To send a message every 5 minutes IBusSession busSession = endpointInstance.CreateBusSession(); busSession.ScheduleEvery(TimeSpan.FromMinutes(5), b => b.Send(new CallLegacySystem())); // Name a schedule task and invoke it every 5 minutes busSession.ScheduleEvery(TimeSpan.FromMinutes(5), "MyCustomTask", SomeCustomMethod); #endregion }
async Task StartBus() { BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.Callbacks.WebSender"); busConfiguration.UseSerialization <JsonSerializer>(); busConfiguration.UsePersistence <InMemoryPersistence>(); busConfiguration.EnableInstallers(); busConfiguration.SendFailedMessagesTo("error"); Endpoint = await NServiceBus.Endpoint.Start(busConfiguration); BusSession = Endpoint.CreateBusSession(); }
static async Task AsyncMain() { BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.Callbacks.Sender"); busConfiguration.UseSerialization <JsonSerializer>(); busConfiguration.UsePersistence <InMemoryPersistence>(); busConfiguration.EnableInstallers(); busConfiguration.SendFailedMessagesTo("error"); IEndpointInstance endpoint = await Endpoint.Start(busConfiguration); try { IBusSession busSession = endpoint.CreateBusSession(); Console.WriteLine("Press 'E' to send a message with an enum return"); Console.WriteLine("Press 'I' to send a message with an int return"); Console.WriteLine("Press 'O' to send a message with an object return"); Console.WriteLine("Press any other key to exit"); while (true) { ConsoleKeyInfo key = Console.ReadKey(); Console.WriteLine(); if (key.Key == ConsoleKey.E) { await SendEnumMessage(busSession); continue; } if (key.Key == ConsoleKey.I) { await SendIntMessage(busSession); continue; } if (key.Key == ConsoleKey.O) { await SendObjectMessage(busSession); continue; } return; } } finally { await endpoint.Stop(); } }
static async Task AsyncStart() { var busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Store.ECommerce"); busConfiguration.PurgeOnStartup(true); busConfiguration.ApplyCommonConfiguration(); busConfiguration.SendFailedMessagesTo("error"); Endpoint = await NServiceBus.Endpoint.Start(busConfiguration); BusSession = Endpoint.CreateBusSession(); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); }