Ejemplo n.º 1
0
        public static int Main()
        {
            var loggerFactory = new LoggerFactory().AddConsole();

            var serviceProvider = SampleServiceProvider.Create(loggerFactory);

            return(TopshelfJob.Run <PingQueueJob>(() => serviceProvider.GetService <PingQueueJob>(), loggerFactory: loggerFactory));
        }
Ejemplo n.º 2
0
        public static int Main()
        {
            var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());

            _logger = loggerFactory.CreateLogger("MessageBus");

            var serviceProvider = SampleServiceProvider.Create(loggerFactory);
            var jobOptions      = JobOptions.GetDefaults <PingQueueJob>(() => serviceProvider.GetRequiredService <PingQueueJob>());
            var messageBus      = serviceProvider.GetRequiredService <IMessageBus>();

            messageBus.SubscribeAsync <EchoMessage>(m => HandleEchoMessage(m)).GetAwaiter().GetResult();
            return(new JobRunner(jobOptions).RunInConsoleAsync().GetAwaiter().GetResult());
        }
Ejemplo n.º 3
0
        public static int Main()
        {
            var loggerFactory = new LoggerFactory().AddConsole((source, level) => {
                if (source.EndsWith("RedisMessageBus"))
                {
                    return(true);
                }

                return(level >= LogLevel.Information);
            });

            _logger = loggerFactory.CreateLogger("MessageBus");

            var serviceProvider = SampleServiceProvider.Create(loggerFactory);
            var jobOptions      = JobOptions.GetDefaults <PingQueueJob>(() => serviceProvider.GetRequiredService <PingQueueJob>());
            var messageBus      = serviceProvider.GetRequiredService <IMessageBus>();

            messageBus.SubscribeAsync <EchoMessage>(m => HandleEchoMessage(m)).GetAwaiter().GetResult();
            return(new JobRunner(jobOptions).RunInConsoleAsync().GetAwaiter().GetResult());
        }