ActiveMQ 5.3 和 NMS 的延迟交付

发布于 2024-10-18 16:00:48 字数 442 浏览 1 评论 0原文

我正在尝试使用 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 技术交流群。

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

发布评论

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

评论(2

何止钟意 2024-10-25 16:00:48

从提供的代码中我没有看到任何明显的内容。

您可以尝试打开代理中的日志记录,以查看调度程序是否收到消息以及值是否正确,这也将确认您确实启用了调度程序支持。您还可以尝试创建一个小型 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

柠檬色的秋千 2024-10-25 16:00:48

感谢您对蒂姆的帮助。我已经找到了问题的原因。我的反应稍有延迟——我必须专注于其他工作领域,但今天我设法回到了这一点。

问题是 C#“.TotalMilliseconds”函数 - 它返回一个小数的 Total.partial 毫秒值,很明显 ActiveMQ 不喜欢这个值。

现在我正在将此毫秒值转换为整数,延迟消息传递按要求工作。

日志摘录如下:

2011-03-07 10:14:44,186 | DEBUG | quasar adding destination: topic://REDACTED | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///REDACTED:50161
2011-03-07 10:14:44,576 | DEBUG | Error occured while processing async command: ActiveMQTextMessage {commandId = 4, responseRequired = false, messageId = ID:HL003323-50159-634350896828327757-0:0:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:HL003323-50159-634350896828327757-0:0:1:1, destination = topic://REDACTED, transactionId = null, expiration = 0, timestamp = 1299492884437, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = org.apache.activemq.util.ByteSequence@1ae0436, dataStructure = null, redeliveryCounter = 0, size = 0, properties = {targetModule=HL.Services.Blackbird.OrderManager, AMQ_SCHEDULED_DELAY=53564.4233}, readOnlyProperties = false, readOnlyBody = false, droppable = false, text = <?xml version="1.0" encoding="utf-16"?>
<Com...mandMessage>}, exception: java.lang.NullPointerException | org.apache.activemq.broker.TransportConnection.Service | ActiveMQ Transport: tcp:///REDACTED:50161
java.lang.NullPointerException
        at org.apache.activemq.broker.scheduler.SchedulerBroker.send(SchedulerBroker.java:179)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:96)
        at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:227)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.security.AuthorizationBroker.send(AuthorizationBroker.java:192)
        at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:135)
        at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:462)
        at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:677)
        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:311)
        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
        at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
        at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
        at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:228)
        at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:220)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
        at java.lang.Thread.run(Thread.java:595)
2011-03-07 10:14:44,577 | WARN  | Async error occurred: java.lang.NullPointerException | org.apache.activemq.broker.TransportConnection.Service | ActiveMQ Transport: tcp:///REDACTED:50161
java.lang.NullPointerException
        at org.apache.activemq.broker.scheduler.SchedulerBroker.send(SchedulerBroker.java:179)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:96)
        at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:227)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.security.AuthorizationBroker.send(AuthorizationBroker.java:192)
        at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:135)
        at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:462)
        at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:677)
        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:311)
        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
        at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
        at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
        at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:228)
        at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:220)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
        at java.lang.Thread.run(Thread.java:595)

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:

2011-03-07 10:14:44,186 | DEBUG | quasar adding destination: topic://REDACTED | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///REDACTED:50161
2011-03-07 10:14:44,576 | DEBUG | Error occured while processing async command: ActiveMQTextMessage {commandId = 4, responseRequired = false, messageId = ID:HL003323-50159-634350896828327757-0:0:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:HL003323-50159-634350896828327757-0:0:1:1, destination = topic://REDACTED, transactionId = null, expiration = 0, timestamp = 1299492884437, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = org.apache.activemq.util.ByteSequence@1ae0436, dataStructure = null, redeliveryCounter = 0, size = 0, properties = {targetModule=HL.Services.Blackbird.OrderManager, AMQ_SCHEDULED_DELAY=53564.4233}, readOnlyProperties = false, readOnlyBody = false, droppable = false, text = <?xml version="1.0" encoding="utf-16"?>
<Com...mandMessage>}, exception: java.lang.NullPointerException | org.apache.activemq.broker.TransportConnection.Service | ActiveMQ Transport: tcp:///REDACTED:50161
java.lang.NullPointerException
        at org.apache.activemq.broker.scheduler.SchedulerBroker.send(SchedulerBroker.java:179)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:96)
        at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:227)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.security.AuthorizationBroker.send(AuthorizationBroker.java:192)
        at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:135)
        at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:462)
        at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:677)
        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:311)
        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
        at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
        at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
        at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:228)
        at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:220)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
        at java.lang.Thread.run(Thread.java:595)
2011-03-07 10:14:44,577 | WARN  | Async error occurred: java.lang.NullPointerException | org.apache.activemq.broker.TransportConnection.Service | ActiveMQ Transport: tcp:///REDACTED:50161
java.lang.NullPointerException
        at org.apache.activemq.broker.scheduler.SchedulerBroker.send(SchedulerBroker.java:179)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.broker.CompositeDestinationBroker.send(CompositeDestinationBroker.java:96)
        at org.apache.activemq.broker.TransactionBroker.send(TransactionBroker.java:227)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.broker.BrokerFilter.send(BrokerFilter.java:129)
        at org.apache.activemq.security.AuthorizationBroker.send(AuthorizationBroker.java:192)
        at org.apache.activemq.broker.MutableBrokerFilter.send(MutableBrokerFilter.java:135)
        at org.apache.activemq.broker.TransportConnection.processMessage(TransportConnection.java:462)
        at org.apache.activemq.command.ActiveMQMessage.visit(ActiveMQMessage.java:677)
        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:311)
        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
        at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
        at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
        at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:228)
        at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:220)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
        at java.lang.Thread.run(Thread.java:595)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文