File tree Expand file tree Collapse file tree 14 files changed +363
-1
lines changed Expand file tree Collapse file tree 14 files changed +363
-1
lines changed Original file line number Diff line number Diff line change 17
17
ruby * /rubygems *
18
18
19
19
java * /.idea /workspace.xml
20
- java * /.idea /encodings.xml
20
+ java * /.idea /encodings.xml
21
+ * ~
Original file line number Diff line number Diff line change
1
+ # Common Lisp code for RabbitMQ tutorials
2
+
3
+ Here you can find Common Lisp code examples from
4
+ [ RabbitMQ tutorials] ( http://cl-rabbit.io/cl-bunny/tutorials/ ) .
5
+
6
+ ## Requirements
7
+
8
+ To run this code you need [ Cl-Bunny] ( http://cl-rabbit.io/cl-bunny ) .
9
+
10
+ You can install it via Quicklisp:
11
+
12
+ (ql:quickload :cl-bunny)
13
+
14
+ Note: Cl-Bunny developed and tested using x64 sbcl on GNU/Linux
15
+
16
+ All our examples are in fact executable sbcl scripts. You can run them from command line
17
+
18
+ ## Code
19
+
20
+ [ Tutorial one: "Hello World!"] ( http://cl-rabbit.io/cl-bunny/tutorials/tutorial-one-cl.html ) :
21
+
22
+ ./send.lisp
23
+ ./receive.lisp
24
+
25
+ [ Tutorial two: Work Queues] ( http://cl-rabbit.io/cl-bunny/tutorials/tutorial-two-cl.html ) :
26
+
27
+ ./new-task.lisp
28
+ ./worker.lisp
29
+
30
+ [ Tutorial three: Publish/Subscribe] ( http://cl-rabbit.io/cl-bunny/tutorials/tutorial-three-cl.html )
31
+
32
+ ./receive-logs.lisp
33
+ ./emit-log.lisp
34
+
35
+ [ Tutorial four: Routing] ( http://cl-rabbit.io/cl-bunny/tutorials/tutorial-four-cl.html )
36
+
37
+ ./receive-logs-direct.lisp
38
+ ./emit-log-direct.lisp
39
+
40
+ [ Tutorial five: Topics] ( http://cl-rabbit.io/cl-bunny/tutorials/tutorial-five-cl.html )
41
+
42
+ ./receive-logs-topic.lisp
43
+ ./emit-log-topic.lisp
44
+
45
+ [ Tutorial six: RPC] ( http://cl-rabbit.io/cl-bunny/tutorials/tutorial-six-cl.html )
46
+
47
+ ./rpc-server.lisp
48
+ ./rpc-client.lisp
49
+
50
+ To learn more, visit [ Cl-Bunny documentation] ( http://cl-rabbit.io/cl-bunny ) site.
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sbcl --noinform --noprint $@ << EOF
4
+
5
+ (ql:quickload :cl-bunny.examples)
6
+
7
+ (in-package :cl-bunny.examples)
8
+
9
+ (with-connection ()
10
+ (with-channel ()
11
+ (let* ((args (rest sb-ext:*posix-argv*))
12
+ (severity (or (first args) "info"))
13
+ (msg (format nil "~{~a~^ ~}" (rest args)))
14
+ (x (exchange.direct "direct_logs")))
15
+ (publish x msg :routing-key severity)
16
+ (format t " [x] Sent '~a'~%" msg))))
17
+
18
+ EOF
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sbcl --noinform --noprint $@ << EOF
4
+
5
+ (ql:quickload :cl-bunny.examples)
6
+
7
+ (in-package :cl-bunny.examples)
8
+
9
+ (with-connection ()
10
+ (with-channel ()
11
+ (let* ((args (rest sb-ext:*posix-argv*))
12
+ (severity (or (first args) "info"))
13
+ (msg (format nil "~{~a~^ ~}" (rest args)))
14
+ (x (exchange.topic "topic_logs")))
15
+ (publish x msg :routing-key severity)
16
+ (format t " [x] Sent '~a'~%" msg))))
17
+
18
+ EOF
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sbcl --noinform --noprint $@ << EOF
4
+
5
+ (ql:quickload :cl-bunny.examples)
6
+
7
+ (in-package :cl-bunny.examples)
8
+
9
+ (with-connection ("amqp://")
10
+ (with-channel ()
11
+ (let ((msg (format nil "~{~a~^ ~}" (cdr sb-ext:*posix-argv*)))
12
+ (x (exchange.fanout "logs")))
13
+ (publish x msg)
14
+ (format t " [x] Sent '~a'~%" msg))))
15
+
16
+ EOF
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sbcl --noinform --noprint $@ << EOF
4
+
5
+ (ql:quickload :cl-bunny.examples)
6
+
7
+ (in-package :cl-bunny.examples)
8
+
9
+ (with-connection ()
10
+ (with-channel ()
11
+ (let ((x (exchange.default))
12
+ (msg (format nil "~{~a~^ ~}" (cdr sb-ext:*posix-argv*))))
13
+ (publish x msg :routing-key "task_queue"
14
+ :properties '(:persistent t))
15
+ (format t " [x] Sent '~a'~%" msg))))
16
+
17
+ EOF
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sbcl --noinform --noprint $@ << EOF
4
+
5
+ (ql:quickload :cl-bunny.examples)
6
+
7
+ (in-package :cl-bunny.examples)
8
+
9
+ (if-let ((args (rest sb-ext:*posix-argv*)))
10
+ (with-connection ()
11
+ (with-channel ()
12
+ (let ((q (queue.declare :auto-delete t))
13
+ (x (exchange.direct "direct_logs")))
14
+ (loop for severity in args do
15
+ (queue.bind q x :routing-key severity))
16
+ (format t " [*] Waiting for logs. To exit press CTRL+C~%")
17
+ (handler-case
18
+ (progn
19
+ (subscribe q (lambda (message)
20
+ (format t " [x] #~a:~a~%" (message-routing-key message) (message-body-string message)))
21
+ :type :sync)
22
+ (consume))
23
+ (sb-sys:interactive-interrupt ()
24
+ (sb-ext:exit))))))
25
+ (format t "Usage: $0 [info] [warning] [error]~%"))
26
+
27
+ EOF
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sbcl --noinform --noprint $@ << EOF
4
+
5
+ (ql:quickload :cl-bunny.examples)
6
+
7
+ (in-package :cl-bunny.examples)
8
+
9
+ (if-let ((args (rest sb-ext:*posix-argv*)))
10
+ (with-connection ()
11
+ (with-channel ()
12
+ (let ((q (queue.declare :auto-delete t))
13
+ (x (exchange.topic "topic_logs")))
14
+ (loop for severity in args do
15
+ (queue.bind q x :routing-key severity))
16
+ (format t " [*] Waiting for logs. To exit press CTRL+C~%")
17
+ (handler-case
18
+ (progn
19
+ (subscribe q (lambda (message)
20
+ (format t " [x] #~a:~a~%" (message-routing-key message) (message-body-string message)))
21
+ :type :sync)
22
+ (consume))
23
+ (sb-sys:interactive-interrupt ()
24
+ (sb-ext:exit))))))
25
+ (format t "Usage: $0 [binding key]~%"))
26
+
27
+ EOF
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sbcl --noinform --noprint << EOF
4
+
5
+ (ql:quickload :cl-bunny.examples)
6
+
7
+ (in-package :cl-bunny.examples)
8
+
9
+ (with-connection ("amqp://")
10
+ (with-channel ()
11
+ (let ((q (queue.declare-temp)))
12
+ (queue.bind q "logs")
13
+ (format t " [*] Waiting for logs. To exit press CTRL+C~%")
14
+ (handler-case
15
+ (progn
16
+ (subscribe q (lambda (message)
17
+ (format t " [x] #~a~%" (message-body-string message)))
18
+ :type :sync)
19
+ (consume))
20
+ (sb-sys:interactive-interrupt ()
21
+ (sb-ext:exit))))))
22
+
23
+ EOF
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ sbcl --noinform --noprint << EOF
4
+
5
+ (ql:quickload :cl-bunny.examples)
6
+
7
+ (in-package :cl-bunny.examples)
8
+
9
+ (with-connection ("amqp://")
10
+ (with-channel ()
11
+ (let ((q (queue.declare :name "hello")))
12
+ (format t " [*] Waiting for messages in queue 'hello'. To exit press CTRL+C~%")
13
+ (handler-case
14
+ (progn
15
+ (subscribe q (lambda (message)
16
+ (format t " [x] Received ~a~%" (message-body-string message)))
17
+ :type :sync
18
+ :no-ack t)
19
+ (consume))
20
+ (sb-sys:interactive-interrupt ()
21
+ (sb-ext:exit))))))
22
+
23
+ EOF
You can’t perform that action at this time.
0 commit comments