-
Notifications
You must be signed in to change notification settings - Fork 9
/
example-streams.lisp
75 lines (54 loc) · 2.63 KB
/
example-streams.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
;;; -*- Package: de.setf.amqp.user; -*-
(in-package :de.setf.amqp.user)
;;; This file demonstrates with-open-channel from the 'de.setf.amqp' library.
;;;
;;; Copyright 2010 [james anderson](mailto:[email protected]
;;; 'de.setf.amqp' is free software: you can redistribute it and/or modify it under the terms of version 3
;;; of the GNU Affero General Public License as published by the Free Software Foundation.
;;;
;;; 'setf.amqp' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
;;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
;;; See the Affero General Public License for more details.
;;;
;;; You should have received a copy of the GNU Affero General Public License along with 'de.setf.amqp'.
;;; If not, see the GNU [site](http://www.gnu.org/licenses/).
;;; to observe the protocol exchange
;;; (setq *log-level* :debug)
(defparameter *c* (make-instance 'amqp:connection :uri "amqp://guest:guest@localhost/"))
(amqp:connection-server-properties *c*)
(amqp:with-open-channel (output *c* :exchange "ex" :type "direct" :queue "q1")
(amqp:basic output :delivery-mode 1)
(format output "~a, ~a, ~a~%"
(lisp-implementation-type)
(lisp-implementation-version)
amqp.u:*version*))
(amqp:with-open-channel (input *c* :queue "q1")
(read-line input))
;;; fails
DEVICE-READ: Required device state USE-CHANNEL.BODY.INPUT is not satisfied by #<USE-CHANNEL
{1001DFFF11}>.
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE] Retry assertion.
1: [ABORT ] Exit debugger, returning to top level.
(SB-KERNEL:ASSERT-ERROR
(TYPEP #:G360 'AMQP.S:USE-CHANNEL.BODY.INPUT)
NIL
"~@[~a: ~]Required device state ~a is not satisfied by ~a."
DEVICE-READ
AMQP.S:USE-CHANNEL.BODY.INPUT
#<AMQP.S:USE-CHANNEL {1001DFFF11}>)
0]
(amqp:with-open-channel (output *c* :exchange "ex" :type "direct" :queue "q1")
(let ((message '("there" "comes" "a" "time" "when" "the" "mind" "takes" "a" "higher" "plane"
"of" "knowledge" "but" "can" "never" "prove" "how" "it" "got" "there")))
(dotimes (x (- (length message) 4) x)
(format output "~d.~{ ~a~}~:[.~;...~]~%" x (subseq message x (+ x 5)) (nth (+ x 5) message)))))
(amqp:with-open-channel (input *c* :queue "q1")
(loop repeat 17 collect (read-line input)))
;; a small problem
(amqp:with-open-channel (input *c* :queue "q1")
(loop
(unless (print (read-line input nil nil))
(return))))
(close *c* :abort t)