                     (.send producer encoded delivery priority ttl)))))
     
 (defn receive 
-  "Receive a message from a destination"
+  "Receive a message from a destination
+
+   The following options are supported [default]:
+    :timeout    time in ms, after which nil is returned [10000]
+    :selector   A JMS (SQL 92) expression matching message properties"
   [dest-name & {:keys [timeout selector]}]
   (with-session (fn [session]
                   (let [destination (destination session dest-name)

                    (and encoded (codecs/decode encoded))))))

(defn message-seq
  "A lazy sequence of messages received from a destination"
  [dest-name]
  (lazy-seq (cons (receive dest-name :timeout 0) (message-seq dest-name))))

(defn listen 
  "The handler function, f, will receive any messages sent to dest-name."
  [dest-name f & {:keys [concurrency] :or {concurrency 1}}]
  (let [connection (.createConnection connection-factory)]
    (try

  only need to do this if you wish to stop the handler's destination
  before your app is undeployed"
  [listener]
  (.close listener))

(defn stop 
  "Destroy a message destination. Typically not necessary since it
  will be done for you when your app is undeployed. This will fail
  with a warning if any handlers are listening"
  [name]
  (if (or (queue? name) (topic? name))
    (stop-destination name)
    (throw (Exception. "Illegal destination name"))))

