Skip to content

Instantly share code, notes, and snippets.

Created January 9, 2018 20:31
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
MassTransit v4 and .NET Core console app to run in a Docker container
using System;
using System.IO;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using GreenPipes;
using MassTransit;
using Microsoft.Extensions.Configuration;
using Serilog;
namespace Abax.Events.Log
internal static class Program
private static IBusControl _busControl;
private static readonly AutoResetEvent WaitHandle = new AutoResetEvent(false);
internal static void Main(string[] args)
AssemblyLoadContext.Default.Unloading += _ => Exit();
Console.CancelKeyPress += (_, __) => Exit();
Serilog.Log.Logger = new LoggerConfiguration()
.Enrich.WithProperty("name", typeof(Program).Assembly.GetName().Name)
var config = new ConfigurationBuilder()
var rmqSettings = config.GetSection("RabbitMq").Get<Configuration.RabbitMq>();
_busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
cfg.PrefetchCount = 50;
var host = cfg.Host(new Uri(rmqSettings.Host), h =>
cfg.ReceiveEndpoint(host, rmqSettings.Endpoint,
ep =>
// Endpoint configuration stuff
private static void Exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment