ActiveMQ .net 客户端锁定

发布于 2024-07-08 03:53:32 字数 1491 浏览 6 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

丢了幸福的猪 2024-07-15 03:53:33

我已经发现了问题所在。 建立连接和消息侦听器后,服务进入 Thread.Sleep(500) 循环。 哑的。 我重构了该服务以在 OnStart 中启动所有内容并在 OnStop 中处理它。

自从这样做以来,一切都运行得很完美。

键盘和椅子之间发生的经典 ID-10-T 错误。

I have discovered the problem. After establishing the connection and the message listener the service went into a loop with Thread.Sleep(500). Dumb. I refactored the service to start everything up in OnStart and dispose of it in OnStop.

Since doing that, everything is running perfectly.

Classic ID-10-T error occurring between keyboard and chair.

忘羡 2024-07-15 03:53:33

我的代码有点不同。 我设置了一个响应“OnMessage”事件的侦听器,而不是循环轮询。 我的代码类似于下面的代码。 我的实际代码中有很多不相关的东西,但精神是一样的。

factory = new Apache.NMS.ActiveMQ.ConnectionFactory("tcp://activemq:61616");

connection = factory.QueueConnection(factory, "MyQueue", AcknowledgementMode.AutoAcknowledge)

consumer = connection.Session.CreateConsumer(connection.Queue, "2 > 1"); //Get every msg

consumer.Listener += new MessageListener(OnMessage);


private void OnMessage(IMessage message)
{
  //Process message here.;
}

My code is a little different. Instead of polling in a loop I set up a listener that responds to an "OnMessage" event. My code is similar to the code below. My actual code has lot of irrelevant stuff in it but the spirit is the same.

factory = new Apache.NMS.ActiveMQ.ConnectionFactory("tcp://activemq:61616");

connection = factory.QueueConnection(factory, "MyQueue", AcknowledgementMode.AutoAcknowledge)

consumer = connection.Session.CreateConsumer(connection.Queue, "2 > 1"); //Get every msg

consumer.Listener += new MessageListener(OnMessage);


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