我有一个 langohr 消息处理程序,它现在只是读取有效负载和标头并打印它们。问题是当我在交易所发布消息时,我无法查询记录的标头(获取标头“h1”),也无法查询本机 clojure 映射。我在这里做错了什么?
(defn status-handler [ch {:keys [headers]} ^bytes payload]
(let [data (String. payload "UTF-8")
status {:status (json/read-str data :key-fn keyword)
:metadata headers}]
(println "job status update: " status)))
发布带有标头的消息时
user => (publish ch "some.topic.exchange" "key1" "{\"id\":1}" {:headers {"h1" "value"}}) nil
输出
作业状态更新:{:status {:id 1}, :metadata #object[java.util.HashMap 0x3cb4bf18 {h1=value}]}