Git Product home page Git Product logo

clomp's Introduction

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"]

clomp's People

Contributors

ninjudd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.