【发布时间】:2016-04-13 12:20:05
【问题描述】:
我有一个应用程序,它使用 Rebus 库通过 Azure ServiceBus 接收消息。
当应用程序作为 Web 应用程序在 Azure 上运行时,与我在本地运行时相比,我观察到了不同的行为。
当它在 Azure 中运行时,我的消息处理程序不会被调用。 当应用程序在本地运行时,一切都按预期工作。
这是我的设置。
在我的 Web 项目 Portal 中,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 连接到服务总线,我可以看到消息在“电子邮件”队列中。但是它确实会留在那里,因此不会被消耗。
非常感谢任何指向设置或天蓝色订阅限制或其他可以帮助我前进的指针。
【问题讨论】:
-
这听起来很奇怪...你能尝试将队列名称的拼写小写吗?
-
我只是这样做了,它确实有效。我有错误的假设,它不区分大小写。非常感谢。您可以将其发布为答案,我会接受。仅供未来的读者阅读。