RabbitMQ 消费者作为 Windows 服务

发布于 2024-12-04 02:57:17 字数 1573 浏览 3 评论 0原文

我在.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铁憨憨 2024-12-11 02:57:17

发现问题,问题是由于任务造成的,创建了一个新线程并在其中执行了订阅代码。工作正常

Found the issue, the problem is due to the Task, Created a new Thread and Executed Subcription code in that. It's working fine

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文