IIS问题中托管的NserviceBus

IIS问题中托管的NserviceBus,nservicebus,Nservicebus,我一直在做一个项目,需要在IIS中托管Nservicebus。 我需要MVC3 webapplication发送消息,nservicebus主机应该处理此消息 然后将某种消息发送回Web应用程序 异步页面示例 展示了一种方法。我可以让这个工作,但这并不完全满足我的要求。我需要从处理程序返回一个对象,而不仅仅是一个int 为了实现这一点,我尝试在IIS下设置主机,在my Global.asax中,我有以下代码: Bus = Configure.WithWeb()

我一直在做一个项目,需要在IIS中托管Nservicebus。 我需要MVC3 webapplication发送消息,nservicebus主机应该处理此消息 然后将某种消息发送回Web应用程序

异步页面示例 展示了一种方法。我可以让这个工作,但这并不完全满足我的要求。我需要从处理程序返回一个对象,而不仅仅是一个int

为了实现这一点,我尝试在IIS下设置主机,在my Global.asax中,我有以下代码:

Bus = Configure.WithWeb()                
               .DefineEndpointName("CQRS")
               .Log4Net()                   
               .DefaultBuilder()                
               .DisableTimeoutManager()                
               .XmlSerializer()
               .MsmqTransport()
                   .IsTransactional(true)
                   .PurgeOnStartup(false)
                   .InMemorySubscriptionStorage()
               .UnicastBus()              
                   .AllowSubscribeToSelf()
                   .ImpersonateSender(false)
                   .LoadMessageHandlers()  
                   .CreateBus().Start();  
my web.config:

<MessageForwardingInCaseOfFaultConfig ErrorQueue="CQRS.error" />
 <MsmqTransportConfig NumberOfWorkerThreads="1" MaxRetries="5"  />

 <UnicastBusConfig  DistributorControlAddress="" DistributorDataAddress="" TimeoutManagerAddress="CQRS.timeouts">
  <MessageEndpointMappings>
     <add Messages="Nokavision.InvoiceProcessing.CQRS.Messages" Endpoint="CQRS" />
     <add Messages="NServiceBus.Scheduling.Messages.ScheduledTask" Endpoint="CQRS" />      
  </MessageEndpointMappings>
</UnicastBusConfig>

使用总线对象发送消息工作正常,消息出现在“cqrs”队列中。 但是,webapplication中的处理程序不会触发。代码如下:

public class UpdateInkoopFactuurAlgemeenHandler : IHandleMessages<UpdateInkoopFactuurAlgemeenCommand>
{
    public IBus Bus { get; set; }

    public void Handle(UpdateInkoopFactuurAlgemeenCommand message)
    {
        P2PEntities entities = new P2PEntities();

        var factuur = (from f in entities.Documenten.OfType<InkoopFactuur>()
                       where f.DocumentId == message.DTO.DocumentId
                       select f).FirstOrDefault();

        if (factuur != null)
        {
            factuur.FactuurNummer = message.DTO.FactuurNummer;
            entities.SaveChanges();
        }

        //Bus.Return(new UpdateInkoopFactuurAlgemeenResponse(message.DTO.ClientConnectionId));

    }
}
公共类updateInkoopFactUuralgeenHandler:IHandleMessages
{
公共IBus总线{get;set;}
public void句柄(updateInkoopfactuuralgeeneCommand消息)
{
P2Penties实体=新的P2Penties();
var factuur=(来自entities.Documenten.OfType()中的f)
其中f.DocumentId==message.DTO.DocumentId
选择f).FirstOrDefault();
如果(factuur!=null)
{
factuur.factuurnumer=message.DTO.factuurnumer;
entities.SaveChanges();
}
//Return(新的updateInkoopfactuuralgeenResponse(message.DTO.ClientConnectionId));
}
}
我确信我在这里遗漏了一些小的东西,但是我做错了什么,为什么在我可以清楚地看到队列中的消息时处理程序没有被触发呢。
在Bus对象上,我还可以看到正在加载处理程序。

好的,我想我已经解决了,似乎NSB创建的队列没有IIS用户的完全访问权限。我已经为每个队列上的每个人设置了“完全控制”,并重新启动了IIS。不知何故,它现在似乎可以工作了

如果您在fluent配置中正确配置安装程序,那么NSB会正确设置队列上的权限。