Hosting is Asp.Net WebForms/MVC

35 views
Skip to first unread message

Brandon Darling

unread,
May 10, 2021, 10:37:36 AM5/10/21
to masstransit-discuss
What is the best way to integrate with full framework asp.net. I found some code that initializes on the application start/end methods. Is this the preferred way. Or would it make sense to use hangfire or something similar for running jobs in the background.

Thanks,

Brandon

public class MvcApplication : System.Web.HttpApplication
  {
    public static IServiceBus Bus {get; set;}
 
    protected void Application_Start()
    {
      AreaRegistration.RegisterAllAreas();
      RouteConfig.RegisterRoutes(RouteTable.Routes);
 
      Bus = BusInitializer.CreateBus("CustomerPortal_WebApp", x => { });
    }
 
    protected void Application_End()
    {
      Bus.Dispose();
    }
  }

public class BusInitializer
  {
    public static IServiceBus CreateBus(string queueName, Action<ServiceBusConfigurator> moreInitialization)
    {
      Log4NetLogger.Use();
      var bus = ServiceBusFactory.New(x =>
      {
        x.UseRabbitMq();
        x.ReceiveFrom("rabbitmq://localhost/Loosely_" + queueName);
        moreInitialization(x);
      });
 
      return bus;
    }
  }

Chris Patterson

unread,
May 10, 2021, 12:22:15 PM5/10/21
to masstrans...@googlegroups.com
That is ancient code, from a seriously outdated version of MassTransit. I'd suggest reading the current documentation:



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/cd7b2c54-7d2b-4117-8722-699654bd2fefn%40googlegroups.com.

Brandon Darling

unread,
May 10, 2021, 2:10:35 PM5/10/21
to masstransit-discuss
The current documentation is geared toward .net core, not full framework. My question is not regarding configuring topshelf, but what is the best way to integrate it into a full framework webforms app. Is it to create/start the bus on  Application_Start and then stop on  Application_End?

Thanks,

Brandon

Chris Patterson

unread,
May 10, 2021, 2:16:56 PM5/10/21
to masstrans...@googlegroups.com
Oh, yeah, sure. I think those are your only start/stop points for .NET Framework apps.

Reply all
Reply to author
Forward
0 new messages