我们在其中一个网站上托管了一个RedisMqServer实例来处理电子邮件。在本地测试时,队列执行完美。部署到Windows Azure时,队列将在启动时处理队列中的所有消息,但几分钟后将无法处理新消息。设置如下:
var mqService = new RedisMqServer(container.Resolve<IRedisClientsManager>());
container.Register<IMessageService>(mqService);
mqService.RegisterHandler<EmailMessage>(ServiceController.ExecuteMessage);
mqService.Start();
发布到队列:
using (var mqClient = TryResolve<IMessageService>().MessageFactory.CreateMessageQueueClient())
{
mqClient.Publish(new EmailMessage
{
From = "support@mysite.com",
To = request.Email,
Subject = "Email Subject",
Body = body
});
}
发布从来没有任何问题。消息成功进入redis mq:EmailMessage.inq。
检查我们看到的工作线程状态:
Worker: mq:EmailMessage.priorityq,
Status: Started, ThreadStatus: Background, WaitSleepJoin,
LastMsgAt: 1/1/0001 12:00:00 AM
Worker: mq:EmailMessage.inq,
Status: Started,
ThreadStatus: Background, WaitSleepJoin,
LastMsgAt: 5/22/2014 9:57:23 PM
这个设置有问题吗?在IIS中托管RedisMqServer是否可以?