ActiveMQ 5.3 和 NMS 的延迟交付
我正在尝试使用 NMS 的新延迟传送功能。
SchedulerSupport 属性已在配置文件中设置,我使用以下代码尝试延迟消息传递,直到到达用户选择的日期/时间。
代码(目前似乎不起作用)如下:
var timeDelay = dateTimePicker.Value.Subtract(DateTime.Now).TotalMilliseconds;
var message = topicPublisher.CreateTextMessage();
message.Properties["AMQ_SCHEDULED_DELAY"] = timeDelay;
message.Text = CM.ToXMLString();
topicPublisher.Send(message);
您能指出这个示例中可能有什么问题吗?
非常感谢!
I'm attempting to use the new delayed delivery functionality from NMS.
The schedulerSupport attribute has been set in the config file, and I'm using the following code to attempt to delay delivery of a message until the date/time chosen by the user is reached.
The code (which does not seem to be working currently) is as follows:
var timeDelay = dateTimePicker.Value.Subtract(DateTime.Now).TotalMilliseconds;
var message = topicPublisher.CreateTextMessage();
message.Properties["AMQ_SCHEDULED_DELAY"] = timeDelay;
message.Text = CM.ToXMLString();
topicPublisher.Send(message);
Can you point out what might be incorrect within this example?
Many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从提供的代码中我没有看到任何明显的内容。
您可以尝试打开代理中的日志记录,以查看调度程序是否收到消息以及值是否正确,这也将确认您确实启用了调度程序支持。您还可以尝试创建一个小型 Java 程序,该程序执行类似的操作来确定 NMS 客户端是否运行正常。
我假设您有一个正在运行的消费者并且其连接对象已启动?
问候
蒂姆.
www.fusesource.com
I don't see anything obvious from the code provided.
You could try turning up the logging in the broker to see if the scheduler receives the message and that the values are correct, that would also confirm that you have indeed enabled scheduler support. You could also try creating a small java program that does something similar to determine if the NMS client is behaving correctly.
I assume you have a consumer running and its connection object has been started?
Regards
Tim.
www.fusesource.com
感谢您对蒂姆的帮助。我已经找到了问题的原因。我的反应稍有延迟——我必须专注于其他工作领域,但今天我设法回到了这一点。
问题是 C#“.TotalMilliseconds”函数 - 它返回一个小数的 Total.partial 毫秒值,很明显 ActiveMQ 不喜欢这个值。
现在我正在将此毫秒值转换为整数,延迟消息传递按要求工作。
日志摘录如下:
Thanks for your help with this Tim. I have found the cause of the issue. Slightly delayed response on my part - I had to concentrate on other areas of work, but I have today managed to come back to this.
The issue is the C# ".TotalMilliseconds" function - this returns a fractional total.partial milliseconds value, which it is apparent that ActiveMQ is not fond of.
Now I'm converting this millisecond value to an integer, the delayed messaging is working as required.
Log Excerpt Below: