static async Task AsyncMain() { LogManager.Use <DefaultFactory>().Level(LogLevel.Info); BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.PubSub.Subscriber2"); busConfiguration.UseSerialization <JsonSerializer>(); busConfiguration.DisableFeature <AutoSubscribe>(); busConfiguration.UsePersistence <InMemoryPersistence>(); busConfiguration.SendFailedMessagesTo("error"); busConfiguration.EnableInstallers(); IEndpointInstance endpoint = await Endpoint.Start(busConfiguration); try { IBusContext busContext = endpoint.CreateBusContext(); await busContext.Subscribe <IMyEvent>(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); await busContext.Unsubscribe <IMyEvent>(); } finally { await endpoint.Stop(); } }
public async Task Subscribe() { IBusContext busContext = null; #region ExplicitSubscribe await busContext.Subscribe <MyEvent>(); await busContext.Unsubscribe <MyEvent>(); #endregion }