activemq 的 persistent

因為希望 ActiveMQ Queue 裡的東西在重新啟動後還能存在,就特別做了實驗,結果真的 Queue 裡的東西會消失。

查了很多的文件,也試了不少設定,像是在 broker 裡設 persistent=”true” (預設本來就是 persistent) 或是加了 jdbcPersistentAdapter 等,都不行,後來才發現是 stompest.async 這邊在送的時候,得特別在 headers 裡加上 {‘persistent’: ‘true’} 才可以讓訊息保存在 Queue 裡。

程式一樣是用官方的範例,主要修改的地方在 producer.py:[python] yield client.send(self.QUEUE, json.dumps(
{‘count’: j}), headers={‘persistent’: ‘true’},
receipt=’message-%d’ % j)
[/python]

這次找資料也找到不少解說 ActiveMQ 的文件: