Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Stomp client library for Clojure.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/clomp
test/clomp
.gitignore
LICENSE
README.md
project.clj
tasks.clj

README.md

clj-stomp is a Streaming Text Oriented Messaging Protocol client library for Clojure. Stomp is a text-based wire format that lets clients communicate through a variety Stomp message brokers, providing interoperable, cross-language messaging.

Getting started

Install a stomp broker and start it up. Both StompServer and CoilMQ don't seem to handle ack:auto correctly, so I've been testing with HornetQ.

git clone git://github.com/jmesnil/hornetq-stomp.git
cd hornetq-stomp
ant server

Usage

You can connect to a message broker using a java.net.Socket:

(require 'stomp)

(with-open [s1 (java.net.Socket. "localhost" 61613)
            s2 (java.net.Socket. "localhost" 61613)]

  (stomp/with-connection s1 {:login "foo" :password "password"}
    (stomp/send s1 {:destination "/queue/foo"} "blah"))

  (stomp/with-connection s2 {:login "bar" :password "secret"}
    (stomp/subscribe s2 {:destination "/queue/foo"})
    (:body (stomp/receive s2))))

=> "blah"

Streams

clj-stomp also supports attaching streams to message queues:

(with-open [s1  (java.net.Socket. "localhost" 61613)
            s2  (java.net.Socket. "localhost" 61613)
            out (stomp/writer s1 {:destination "/queue/a"})
            in  (stomp/reader s2)]

  (stomp/with-connection s1 {:login "foo" :password "password"}
    (binding [*out* out]
      (println "foo")
      (println "bar")
      (println "baz")))

  (stomp/with-connection s2 {:login "bar" :password "secret"}
    (stomp/subscribe s2 {:destination "/queue/a"})
    (binding [*in* in]
      [(read-line)
       (read-line)
       (read-line)))))

=> ["foo", "bar", "baz"]
Something went wrong with that request. Please try again.