forked from rnewman/clojure-rabbitmq
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added example scripts; implemented consume-wait
- Loading branch information
Showing
5 changed files
with
70 additions
and
44 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,29 @@ | ||
(ns rabbitmq.consumer.test | ||
(:require [com.github.icylisper.rabbitmq :as rabbitmq])) | ||
|
||
(defonce conn-map { :username "guest" | ||
:password "guest" | ||
:host "localhost" | ||
:port 5672 | ||
:virtual-host "/" | ||
:type "direct" | ||
:exchange "sorting-room" | ||
:queue "po-box" | ||
:routing-key "tata"}) | ||
|
||
(defonce connection (rabbitmq/connect conn-map)) | ||
|
||
(def c (ref 0)) | ||
|
||
(while true | ||
(dosync (alter c inc)) | ||
(println "cycle: " @c) | ||
|
||
;; publish | ||
(let [[_ channel] connection | ||
message (rabbitmq/consume-wait conn-map channel)] | ||
(println "rabbitmq consumer : got message" message)) | ||
|
||
(Thread/sleep 1000)) | ||
|
||
|
File renamed without changes.
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,31 @@ | ||
(ns rabbitmq.publisher | ||
(:require [com.github.icylisper.rabbitmq :as rabbitmq])) | ||
|
||
(defonce conn-map { :username "guest" | ||
:password "guest" | ||
:host "localhost" | ||
:port 5672 | ||
:virtual-host "/" | ||
:type "direct" | ||
:exchange "sorting-room" | ||
:queue "po-box" | ||
:routing-key "tata"}) | ||
|
||
(defonce connection (rabbitmq/connect conn-map)) | ||
|
||
(def c (ref 0)) | ||
|
||
(while true | ||
(dosync (alter c inc)) | ||
(println "cycle: " @c) | ||
|
||
;; publish | ||
(let [[conn channel] connection] | ||
(do | ||
(rabbitmq/bind-channel conn-map channel) | ||
(println "rabbitmq publishing:" (format "message%d" @c)) | ||
(rabbitmq/publish conn-map channel (format "message%d" @c)))) | ||
|
||
(Thread/sleep 1000)) | ||
|
||
|
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
This file was deleted.
Oops, something went wrong.