2016-04-13 52 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有關。

你可以嘗試使它小寫嗎?