Skip to content

Commit 6aa023e

Browse files
committedMar 2, 2016
common-lisp: tutorial three code
1 parent ccbf823 commit 6aa023e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
 

‎common-lisp/emit-log.lisp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

‎common-lisp/receive-logs.lisp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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

0 commit comments

Comments
 (0)
Please sign in to comment.