Skip to content

Commit

Permalink
Version 0.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbtourist committed Aug 19, 2011
1 parent b772640 commit c9a89ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Clamq - Clojure APIs for Message Queues - Version 0.3 (WORK IN PROGRESS)
# Clamq - Clojure APIs for Message Queues - Version 0.3

Clamq is a Clojure adpater for interacting with message queues, providing simple APIs to connect to brokers and sending/consuming messages to/from message queues and topics.

Expand All @@ -14,7 +14,9 @@ Clamq supports **JMS** and **AMQP** brokers, more specifically:

Clamq can be configured in your Leiningen project file as follows:

[clamq "0.3-SNAPSHOT"]
[clamq "0.3"]

It is available on Clojars, so everything should be pretty straightforward.

Also, depending on the broker you want to connect to, you need to declare the related dependency.

Expand Down Expand Up @@ -118,13 +120,15 @@ Where:
The **endpoint** definition depends on the actual broker:
for JMS brokers, it is just the queue/topic name, for AMQP brokers it is a map containing two entries, *:exchange* and *:routing-key*.

### Asynchronous message consumers
### Message consumers

Message consumers work by asynchronously pulling messages from the queue they listen to, and processing them through a user-defined function.

In order to use asynchronous message consumers, you need the following namespaces:
In order to start consuming messages, you need the following namespaces:

(use 'clamq.protocol.consumer)

Now you can define an asynchronous consumer as follows:
Now you can define the consumer as follows:

(consumer connection configuration)

Expand All @@ -136,7 +140,7 @@ Where:
The configuration map currently supports the following keys (mandatory, except where differently noted):

* **:endpoint** is the name of a message queue endpoint to consume from.
* **:on-message** is the handler function to call at each consumed message, accepting the message itself as unique argument.
* **:on-message** is the handler function called at each consumed message, accepting the message itself as unique argument.
* **:transacted** defines (true/false) if the message consumption must be locally transactional.
* **:pubSub** in only valid for JMS brokers, and defines if consumer messages are from publish/subscribe, that is, must be consumed from a topic (optional).
* **:limit** defines the max number of consumed messages, after which the consumer stops itself (optional: defaults to 0, unlimited).
Expand All @@ -150,15 +154,15 @@ Once defined, asynchronous consumers can be started and closed as follows:
(start consumer)
(close consumer)

### Synchronous (seqable) message consumers
### Message sequences

In order to use synchronous message consumers, you need the following namespaces:
Message sequences are synchronous consumers based on Clojure lazy sequences, consuming messages only when actually requested to do so.

(use 'clamq.protocol.seqable)
In order to establish a message sequence, you need the following namespaces:

Synchronous message consumers are based on Clojure lazy sequences, consuming messages only when actually requested to do so.
(use 'clamq.protocol.seqable)

First you need to define a synchronous consumer as follows:
Then, you need to define a seqable consumer, which will act as the provider for the message sequence:

(def consumer (seqable connection configuration))

Expand Down Expand Up @@ -187,7 +191,7 @@ So here's a simple example about how to move all available messages from your se
(reduce into []
(map #(do (ack consumer) [%1]) (mseq consumer))))

Finally, synchronous consumers must be closed as follows:
Finally, seqable consumers (with related message sequence) must be closed as follows:

(close consumer)

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject clamq "0.3-SNAPSHOT"
(defproject clamq "0.3"
:description "Clojure APIs for Message Queues"
:dependencies [
[org.clojure/clojure "1.2.1"]
Expand Down

0 comments on commit c9a89ae

Please sign in to comment.