RabbitMQ 消费者作为 Windows 服务
我在.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。有人遇到类似的问题吗?
i have a rabbitmq consumer application in .net, which runs perfectly as a console applicaiton. but if i deploy that as a windows service i am getting the following error.
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
and the code failing is
using (_subscription = new Subscription(_channel, _queue, false))
{
foreach (BasicDeliverEventArgs e in _subscription)
{
EventLog.WriteEntry("RBSubService", "in first line", EventLogEntryType.Error);
yield return e;
}
}
this code fails only if it is deployed as windows service
I am using windows7. anyone faced similar problem??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发现问题,问题是由于任务造成的,创建了一个新线程并在其中执行了订阅代码。工作正常
Found the issue, the problem is due to the Task, Created a new Thread and Executed Subcription code in that. It's working fine