-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Klishin
committed
Aug 4, 2013
1 parent
54f5aac
commit 3c99326
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/target | ||
/lib | ||
/classes | ||
/checkouts | ||
pom.xml | ||
pom.xml.asc | ||
*.jar | ||
*.class | ||
.lein-* | ||
bin/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Clojure code for RabbitMQ tutorials | ||
|
||
Here you can find Ruby code examples from | ||
[RabbitMQ tutorials](http://www.rabbitmq.com/getstarted.html). | ||
|
||
## Requirements | ||
|
||
To run this code you need [Langohr](http://clojurerabbitmq.info). | ||
|
||
Dependencies are managed by [Leiningen](http://leiningen.org). | ||
|
||
These tutorials only require JDK 6 or 7 (Oracle or OpenJDK). | ||
|
||
## Code | ||
|
||
Code examples are executed via `lein run`: | ||
|
||
[Tutorial one: "Hello World!"](http://www.rabbitmq.com/tutorial-one-java.html): | ||
|
||
lein run -m "rabbitmq.tutorials.send" | ||
lein run -m "rabbitmq.tutorials.receive" | ||
|
||
[Tutorial two: Work Queues](http://www.rabbitmq.com/tutorial-two-java.html): | ||
|
||
lein run -m "rabbitmq.tutorials.new-task" | ||
lein run -m "rabbitmq.tutorials.worker" | ||
|
||
[Tutorial three: Publish/Subscribe](http://www.rabbitmq.com/tutorial-three-java.html) | ||
|
||
ruby receive_logs.rb | ||
ruby emit_log.rb | ||
|
||
[Tutorial four: Routing](http://www.rabbitmq.com/tutorial-four-java.html) | ||
|
||
ruby receive_logs_direct.rb | ||
ruby emit_log_direct.rb | ||
|
||
[Tutorial five: Topics](http://www.rabbitmq.com/tutorial-five-java.html) | ||
|
||
ruby receive_logs_topic.rb | ||
ruby emit_log_topic.rb | ||
|
||
[Tutorial six: RPC](http://www.rabbitmq.com/tutorial-six-java.html) | ||
|
||
ruby rpc_server.rb | ||
ruby rpc_client.rb | ||
|
||
To learn more, visit [Langohr documentation](http://clojurerabbitmq.info) site. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(defproject com.rabbitmq/tutorials "1.0.0-SNAPSHOT" | ||
:description "RabbitMQ tutorials using Langohr" | ||
:url "http://github.com/rabbitmq/rabbitmq-tutorial" | ||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
:dependencies [[org.clojure/clojure "1.5.1"] | ||
[com.novemberain/langohr "1.3.0"]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(ns rabbitmq.tutorials.receive | ||
(:require [langohr.core :as lc] | ||
[langohr.channel :as lch] | ||
[langohr.queue :as lq] | ||
[langohr.consumers :as lcons])) | ||
|
||
(defn handle-delivery | ||
"Handles message delivery" | ||
[ch metadata payload] | ||
(println (format " [x] Received %s" (String. payload "UTF-8")))) | ||
|
||
(defn -main | ||
[& args] | ||
(with-open [conn (lc/connect)] | ||
(let [ch (lch/open conn)] | ||
(lq/declare ch "hello" :durable false :auto-delete false) | ||
(println " [*] Waiting for messages. To exit press CTRL+C") | ||
(lcons/blocking-subscribe ch "hello" handle-delivery :auto-ack true)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(ns rabbitmq.tutorials.send | ||
(:require [langohr.core :as lc] | ||
[langohr.channel :as lch] | ||
[langohr.queue :as lq] | ||
[langohr.basic :as lb])) | ||
|
||
|
||
(defn -main | ||
[& args] | ||
(with-open [conn (lc/connect)] | ||
(let [ch (lch/open conn)] | ||
(lq/declare ch "hello" :durable false :auto-delete false) | ||
(lb/publish ch "" "hello" (.getBytes "Hello World!" "UTF-8")) | ||
(println " [x] Sent 'Hello World!'")))) |