Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No single method [...] found for function" trying to use a protocol

Tags:

clojure

I have a Clojure library which defines a MQHandle protocol, and extends it

(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"
   ...)

...but when I try to use it:

(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

I don't grok the meaning of this exception, or what I should be doing differently.

like image 415
Charles Duffy Avatar asked May 03 '12 16:05

Charles Duffy


1 Answers

Protocol functions don't support rest arguments.

like image 64
dnolen Avatar answered Oct 02 '22 06:10

dnolen