Skip to content

Commit

Permalink
common-lisp: tutorial three code
Browse files Browse the repository at this point in the history
  • Loading branch information
deadtrickster committed Mar 2, 2016
1 parent ccbf823 commit 6aa023e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions common-lisp/emit-log.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

sbcl --noinform --noprint $@ <<EOF
(ql:quickload :cl-bunny.examples)
(in-package :cl-bunny.examples)
(with-connection ("amqp://")
(with-channel ()
(let ((msg (format nil "~{~a~^ ~}" (cdr sb-ext:*posix-argv*)))
(x (exchange.fanout "logs")))
(publish x msg)
(format t " [x] Sent '~a'~%" msg))))
EOF
23 changes: 23 additions & 0 deletions common-lisp/receive-logs.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

sbcl --noinform --noprint <<EOF
(ql:quickload :cl-bunny.examples)
(in-package :cl-bunny.examples)
(with-connection ("amqp://")
(with-channel ()
(let ((q (queue.declare-temp)))
(queue.bind q "logs")
(format t " [*] Waiting for logs. To exit press CTRL+C~%")
(handler-case
(progn
(subscribe q (lambda (message)
(format t " [x] #~a~%" (message-body-string message)))
:type :sync)
(consume))
(sb-sys:interactive-interrupt ()
(sb-ext:exit))))))
EOF

0 comments on commit 6aa023e

Please sign in to comment.