Ejemplo n.º 1
0
    static async Task AsyncMain()
    {
        LoggingConfig.ConfigureNLog();
        LogManager.Use <NLogFactory>();

        var endpointConfiguration = new EndpointConfiguration("NLogSample");

        endpointConfiguration.UseSerialization <JsonSerializer>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.SendFailedMessagesTo("error");
        endpointConfiguration.UsePersistence <InMemoryPersistence>();
        var endpoint = await Endpoint.Start(endpointConfiguration);

        try
        {
            await endpoint.SendLocal(new MyMessage());

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
Ejemplo n.º 2
0
    static void Main()
    {
        LoggingConfig.ConfigureNLog();
        LogManager.Use <NLogFactory>();

        var busConfig = new BusConfiguration();

        busConfig.EndpointName("NLogSample");
        busConfig.UseSerialization <JsonSerializer>();
        busConfig.EnableInstallers();
        busConfig.UsePersistence <InMemoryPersistence>();
        using (var bus = Bus.Create(busConfig))
        {
            bus.Start();
            bus.SendLocal(new MyMessage());
            Console.WriteLine("\r\nPress any key to stop program\r\n");
            Console.Read();
        }
    }