2016-04-13 47 views
1

我有一个应用程序使用Rebus库通过Azure ServiceBus接收消息。在部署到Azure时未调用MessageHandlers

与当我在本地运行应用程序时相比,当应用程序作为Web应用程序在Azure上运行时,我观察到不同的行为。

当它在Azure中运行时,我的消息处理程序未被调用。 当应用程序在本地运行时,一切都按预期工作。

这是我的设置。

在我的web项目门户的Global.asax.cs:

protected void Application_Start() 
    { 
     _webContainer = new WindsorContainer(); 
     _queueContainer = new WindsorContainer(); 
     ConfigureWebContainer(); 
     _queueContainer.Install(FromAssembly.Containing<ServiceBusInstaller>()); 

     ApplicationInsightsConfig.Configure(); 
    } 

在项目ServiceBus(其中ServiceBusInstaller谎言)

public void Install(IWindsorContainer container, IConfigurationStore store) 
{ 
    var adapter = new CastleWindsorContainerAdapter(container); 
    var connectionString = CloudConfigurationManager.GetSetting("QueueUrl"); 

    var configurer = Configure 
    .With(adapter) 
    .Options(o => 
    { 
     o.SimpleRetryStrategy(maxDeliveryAttempts: 0); 
    }) 
    .Logging(l => l.Log4Net()) 
    .Routing(r => r.TypeBased() 
     .MapAssemblyOf<ResetPasswordMessage>("Email")) 
    Transport(t => t.UseAzureServiceBus(connectionString, "Email")); 
    // Create and starts the bus 
    configurer.Start(); 
} 

我ResetPasswordHandler看起来是这样的:

public class ResetPasswordHandler : IHandleMessages<ResetPasswordMessage> 
{ 
    private readonly IContactAndEmailService _contactAndEmailService; 

    public ResetPasswordHandler(IContactAndEmailService contactAndEmailService) 
    { 
     _contactAndEmailService = contactAndEmailService; 
    } 

    public async Task Handle(ResetPasswordMessage message) 
    { 
     _contactAndEmailService.SendEmail(message); 
    } 
} 

我正在使用Service Bus Explorer连接到服务器冰巴士,我可以看到消息在“电子邮件”队列中。但是它停留在那里,因此不会被消耗。

任何指向设置或天蓝色订阅限制或其他可以帮助我前进的指针都是非常感谢。

+1

这听起来很奇怪......你可以尝试小写拼写的队列名称吗? – mookid8000

+1

我刚刚做到了,它确实有效。我有错误的假设,它是不区分大小写的。非常感谢。您可以将它作为答案发布,我会接受它。只为未来的读者。 – AndreasPK

回答

1

我认为这可能与队列名称的外壳Email有关。

你可以尝试使它小写吗?