"没有单一的方法[...]找到功能"尝试使用协议

Cha*_*ffy 6 clojure

我有一个Clojure库,它定义了一个MQHandle协议,并对其进行了扩展

(ns example.mq
  (:import [java.util.concurrent BlockingQueue]))

(defprotocol MQHandle
  (send-message [this key body & params])

(extend-type BlockingQueue
  MQHandle
  (send-message [this key body & params]
    (.put this (merge {::key key, ::body body}
                      (into {} (partition 2 params)))))

(defn get-handle ^BlockingQueue [& config]
   "return a BlockingQueue tied to a thread which consumes messages
   and submits them to a remote message queue"
   ...)
Run Code Online (Sandbox Code Playgroud)

...但是当我尝试使用它时:

(require '[example.mq :as mq])

(def handle (mq/get-handle config))

(satisfies? mq/MQHandle handle)
; => true

(mq/send-message handle "key" "body")
; java.lang.IllegalArgumentException: No single method: send_message of interface:
;  com.indeed.clojure_network_repl.mq.MQHandle found for function: send-message of
;  protocol: MQHandle
Run Code Online (Sandbox Code Playgroud)

我不了解这个例外的含义,或者我应该采取不同的做法.

dno*_*len 12

协议函数不支持rest参数.