在MVC6中处理NServiceBus总线实例
在以前的ASP.Net版本中,NServiceBus示例声明在global.asax中创建一个总线实例。然后在处理应用程序时(在global.asax中),将处理前面提到的总线实例。有点像下面的缩写版本:在MVC6中处理NServiceBus总线实例,nservicebus,asp.net-core,asp.net-core-mvc,Nservicebus,Asp.net Core,Asp.net Core Mvc,在以前的ASP.Net版本中,NServiceBus示例声明在global.asax中创建一个总线实例。然后在处理应用程序时(在global.asax中),将处理前面提到的总线实例。有点像下面的缩写版本: IBus bus; protected void Application_Start() { //Bunch of bus configuration and controller registration etc... //Now Create the bus and as
IBus bus;
protected void Application_Start()
{
//Bunch of bus configuration and controller registration etc...
//Now Create the bus and assign to a local variable so we can dispose it
var startableBus = Bus.Create(busConfiguration);
bus = startableBus.Start();
}
public override void Dispose()
{
if (bus != null)
{
bus.Dispose();
}
base.Dispose();
}
但在vNext中,据我所知,Startup.cs中没有dispose。是否应该保留一个总线实例并以某种方式进行处理?vNext是否应该遵循其他模式
谢谢 如果我没有弄错的话,看起来您将
iaapplicationlifetime
添加到Configure
中,然后等待ApplicationStopping
被取消
以下是一个片段:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory, IApplicationLifetime lifetime)
{
// New up/start bus here
lifetime.ApplicationStopping.Register(() =>
{
// Stop the bus here
});
而且看起来他们计划有一个新的版本,所以一旦发布,我们应该能够在那里启动总线。在应用程序启动之前,总线不应该运行吗?听起来这只是要求一个竞赛条件。。。(除非有某种保证,在所有
应用程序启动
处理程序执行之前,请求不会到达)