我在.net中有一个rabbitmq消费者应用程序,它完美地作为控制台应用程序运行。但如果我将其部署为Windows服务,我会收到以下错误。
RabbitMQ.Client.Exceptions.OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Application, code=200, text="Goodbye", classId=0, methodId=0, cause=
at RabbitMQ.Client.Impl.SimpleBlockingRpcContinuation.GetReply()
at RabbitMQ.Client.Impl.ModelBase.BasicConsume(String queue, Boolean noAck, String consumerTag, Boolean noLocal, Boolean exclusive, IDictionary arguments, IBasicConsumer consumer)
at RabbitMQ.Client.Impl.ModelBase.BasicConsume(String queue, Boolean noAck, String consumerTag, IDictionary arguments, IBasicConsumer consumer)
at RabbitMQ.Client.Impl.ModelBase.BasicConsume(String queue, Boolean noAck, String consumerTag, IBasicConsumer consumer)
at RabbitMQ.Client.Impl.ModelBase.BasicConsume(String queue, Boolean noAck, IBasicConsumer consumer)
at RbMQSubscriber.RabbitDataService.Subscribe() in C:\Projects\RabbitMqServices\RbMQClient\RabbitDataService.cs:line 72
at RbMQPublisherService.Service1.backGroundWorker_DoWork(Object sender, DoWorkEventArgs e) in C:\Projects\RabbitMqServices\RbMQSubscriberService\RbMQSubscriberService.cs:line 76
并且代码失败的是
using (_subscription = new Subscription(_channel, _queue, false))
{
foreach (BasicDeliverEventArgs e in _subscription)
{
EventLog.WriteEntry("RBSubService", "in first line", EventLogEntryType.Error);
yield return e;
}
}
此代码仅在部署为Windows服务时才会失败 我正在使用windows7。有人遇到过类似的问题吗?
答案 0 :(得分:1)
发现问题,问题是由于Task,在其中创建了一个新的Thread和Executed Subcription代码。它工作正常