首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用AMQ_SCHEDULED_DELAY时,stomp.py不会延迟消息

使用AMQ_SCHEDULED_DELAY时,stomp.py不会延迟消息
EN

Stack Overflow用户
提问于 2017-04-25 20:21:38
回答 1查看 1.5K关注 0票数 1

我正在码头容器上运行ActiveMQ服务器。

我正在使用AMQ_SCHEDULED_DELAY头来延迟消息。

代码语言:javascript
复制
import time
import sys

import stomp

class MyListener(stomp.ConnectionListener):
    def on_error(self, headers, message):
        print('received an error "%s"' % message)
    def on_message(self, headers, message):
        print "Time for message receive: %s", time.strftime('%H:%M:%S')
        print('received a message "%s"' % message)

conn = stomp.Connection()
conn.set_listener('', MyListener())
conn.start()
conn.connect(wait=True)

conn.subscribe(destination='/queue/test', id=1, ack='auto')

print "Time for send message: %s", time.strftime('%H:%M:%S')
conn.send(body=' '.join(sys.argv[1:]), destination='/queue/test', headers={'AMQ_SCHEDULED_DELAY': 100000})

time.sleep(2)
conn.disconnect()

输出:

代码语言:javascript
复制
test@localhost$ python /tmp/test.py this is test
Time for send message: %s 14:03:34
Time for message receive: %s 14:03:34
received a message "this is test"

从输出上看,它似乎不起作用,或者我必须从ActiveMQ端更新一些东西。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-25 20:58:00

通过将broker schedulerSupport属性设置为activemq.xml中的true来启用它:

代码语言:javascript
复制
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}" schedulerSupport="true">  

http://activemq.apache.org/delay-and-schedule-message-delivery.html

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43620262

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档