简体   繁体   English

STOMP选择器Python对于ActiveMq

[英]STOMP selectors Python For ActiveMq

I am trying to get this script to work, I need to filter a Stompy subscription on the custom header field "Test". 我正在尝试使此脚本正常工作,我需要在自定义标头字段“测试”中过滤Stompy订阅。

But every time i try, it doesn't get received, I can see the message in the queue fine, but the subscriber never takes it off the queue. 但是,每次尝试,它都不会被接收,我可以看到队列中的消息很好,但是订阅者永远不会将其从队列中删除。 When I remove the selector statement in the subscriber, I can receive the message. 当我在订阅服务器中删除选择器语句时,我可以收到消息。

Could someone tell me what I am doing wrong? 有人可以告诉我我在做什么错吗?

#!/usr/bin/python

from stompy.simple import Client
import json

Dict_Message = dict()
Dict_Message["Test1"] = "CONDOR"

stomp = Client("localhost", 61613)
stomp.connect("producer", "pass")
stomp.put(json.dumps(Dict_Message), destination="/queue/test",conf={'Test':'Test123'})
stomp.disconnect()

stomp = Client("localhost", 61613)
stomp.connect("consumer", "pass")
stomp.subscribe("/queue/test",conf={'selector' : "'Test' = 'Test123'"})
#stomp.subscribe("/queue/test")
message = stomp.get()

print message.headers
New_Dict = json.loads(message.body)
print New_Dict
stomp.ack(message)
stomp.unsubscribe("/queue/test")
stomp.disconnect()

Do not use the '' in the name of field in the selector. 不要在选择器的字段名称中使用“”。 The syntax in the selector is like SQL, it is not like JSON. 选择器中的语法就像SQL,而不像JSON。

stomp.subscribe("/queue/test",conf={'selector' : "Test = 'Test123'"})

In fact, I don´t use tiles at all in the text of the selector. 实际上,我在选择器的文本中根本不使用磁贴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM