我有一個Windows服務,從RabbitMQ隊列中檢索消息。該服務在Windows 7計算機上本地運行。當我在Windows 2008服務器上安裝服務時,它不起作用(並且不會引發任何錯誤)。我的ASP.net MVC應用程序可以將消息發佈到同一個隊列。這裏可能有防火牆或安全問題嗎?我應該從RabbitMQ中檢索不同於以下的郵件嗎?RabbitMQ消費者
public void PullFromQueue()
{
var connectionFactory = new ConnectionFactory();
using (var connection = connectionFactory.CreateConnection())
using (var channel = connection.CreateModel())
{
var consumer = new QueueingBasicConsumer(channel);
channel.ExchangeDeclare(ExchangeName, ExchangeType.Direct, true);
channel.QueueDeclare(QueueName, true);
channel.QueueBind(QueueName, ExchangeName, RoutingKey, false, null);
channel.BasicConsume(QueueName, null, consumer);
while (true)
{
try
{
var e = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
var props = e.BasicProperties;
props.DeliveryMode = PersistentDelivery;
var businessObject = DeserializeBusinessObject(e.DeliveryTag, e.Body);
processBusinessObject(businessObject);
channel.BasicAck(e.DeliveryTag, false);
}
catch (Exception ex)
{
Log<RabbitMQWrapper>.Error("Error in pulling Business Object from Queue", ex);
}
}
}
}