Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
clojure distributed queue on top of redis
Clojure
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/rstoker
.gitignore
README.md
project.clj

README.md

rstoker is a distributed queue on top of redis

Usage

(ns sandbox
 (:require rstoker.queue])
 (:import rstoker.queue.MessageQueue))

(def config {:hosts       [{:host "localhost" :port 6377 :timeout 200}
                           {:host "localhost" :port 6378 :timeout 200}
                           {:host "localhost" :port 6379 :timeout 200}]
             :config      {:max-active 10
                           :max-idle   10
                           :max-wait   200}})

(def consumer (MessageQueue. config nil))
(def consumer (.connect consumer))

(doseq [msg (.next_message 1 "some-q-name")]
  (do-something-with msg))

(def producer (MessageQueue. config nil))
(def producer (.connect producer))

(.enqueue producer "some-q-name" {:some :object})

Lamina Interface

(ns sandbox
  (:require [lamina.core :as lamina]
            [rstoker.lamina :as rstoker]))

(def config {:hosts       [{:host "localhost" :port 6377 :timeout 200}
                           {:host "localhost" :port 6378 :timeout 200}
                           {:host "localhost" :port 6379 :timeout 200}]
             :config      {:max-active 10
                           :max-idle   10
                           :max-wait   200}})

(def consumer (rstoker/async-consumer config 1 "some-q-name"))
(def producer (rstoker/async-producer config))

(lamina/receive-all consumer #(println "got message: " %))
(lamina/enqueue producer {:topic "some-q-name" :data {:some :map})

Semantics

This is very early work, beware of the following caveats:

  • failed produces on a host do not trigger a retry on the rest of the available hosts
  • next_message blocks indefinitely, waiting for a message, the timeout argument is just the maximum time to wait per host before switching to the next available host.

Installation

The easiest way to use rstoker in your own projects is via Leiningen. Add the following dependency to your project.clj file:

[rstoker   "0.3.2"]

If you would rather use maven, you need to specify the clojars repository dependency and import the rstoker artifact

<repository>
    <id>clojars.org</id>
    <url>http://clojars.org/repo</url>
</repository>

<dependency>
    <groupId>rstoker</groupId>
    <artifactId>rstoker</artifactId>
    <version>0.3.2</version>
</dependency>

License

Copyright (C) 2012 Pierre-Yves Ritschard

Distributed under the MIT License

Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF

Something went wrong with that request. Please try again.