2017-04-25 8 views
1

도커 컨테이너에 ActiveMQ 서버가 실행 중입니다.stomp.py를 사용할 때 AMQ_SCHEDULED_DELAY 메시지가 지연되지 않음

메시지를 지연 시키려면 AMQ_SCHEDULED_DELAY 헤더를 사용하고 있습니다.

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() 

출력 : 출력에서 ​​

[email protected]$ 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를 측면에서 뭔가를 업데이트해야합니다.

답변

3

그것은이 activemq.xml에서 true로 브로커 schedulerSupport 특성을 설정하여 사용할 수 있습니다 :

<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

+0

하센을 기본 설정으로이 어떤 고정 표시기 이미지가? 나는 내 배치를 위해'activemq' docker를 사용하고 있습니다. – Nilesh

+0

솔직히 모르겠습니다. –

+0

감사합니다. Hassen, 찾을 것입니다. – Nilesh