forked from rabbitmq/rabbitmq-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.lisp
executable file
·28 lines (23 loc) · 903 Bytes
/
worker.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
sbcl --noinform --noprint <<EOF
(ql:quickload :cl-bunny.examples)
(in-package :cl-bunny.examples)
(with-connection ()
(with-channel ()
(let ((q (queue.declare :name "task_queue" :durable t)))
(format t " [*] Waiting for messages in queue 'task_queue'. To exit press CTRL+C~%")
(qos :prefetch-count 1)
(handler-case
(progn
(subscribe q (lambda (message)
(let ((body (message-body-string message)))
(format t " [x] Received '~a'~%" body)
;; imitate some work
(sleep (count #\. body))
(message.ack message)
(format t " [x] Done~%")))
:type :sync)
(consume))
(sb-sys:interactive-interrupt ()
(sb-ext:exit))))))
EOF