2014-10-28 36 views
0

我試圖讓這個腳本工作,我需要篩選自定義標題字段「測試」上的Stompy訂閱。STOMP選擇器Python對於ActiveMq

但是,每次我嘗試,它都沒有收到,我可以看到隊列中的消息正常,但用戶永遠不會把它從隊列中取出。當我刪除用戶中的選擇器語句時,我可以收到該消息。

有人能告訴我我做錯了什麼嗎?

#!/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() 

回答

1

請勿在選擇器中的字段名稱中使用'''。選擇器中的語法就像SQL,它不像JSON。

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

實際上,我在選擇器的文本中根本不使用拼貼。