lynnroth / NancyMassTransitTest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change Bootstrapper (and use the next release of MT)

phatboyg opened this issue · comments

namespace API
{
using System;
using System.Configuration;
using MassTransit;
using Nancy;
using Nancy.TinyIoc;

public class Bootstrapper : DefaultNancyBootstrapper
{
    string MessageQueueServer = ConfigurationManager.AppSettings["MessageQueueServer"];
    string password = ConfigurationManager.AppSettings["MessageQueuePassword"];
    string username = ConfigurationManager.AppSettings["MessageQueueUsername"];

    protected override void ConfigureApplicationContainer(TinyIoCContainer container)
    {
        base.ConfigureApplicationContainer(container);

        var uri = new Uri($"rabbitmq://{MessageQueueServer}/");

        var bus = Bus.Factory.CreateUsingRabbitMq(x =>
        {
            x.Host(uri, h =>
            {
                h.Username(username);
                h.Password(password);
                h.Heartbeat(5);
            });

            x.Durable = true;
        });

        bus.Start();

        container.Register(bus);
    }
}

}