/[de-setf-amqp]/readmes/example-streams.lisp
ViewVC logotype

Contents of /readmes/example-streams.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Tue Feb 23 09:05:39 2010 UTC (4 years, 1 month ago) by janderson
File size: 1988 byte(s)
Merge commit 'remotes/github/master' into remotes/git-svn
1 ;;; -*- Package: de.setf.amqp.user; -*-
2
3 (in-package :de.setf.amqp.user)
4
5 ;;; This file demonstrates with-open-channel from the 'de.setf.amqp' library.
6 ;;;
7 ;;; Copyright 2010 [james anderson](mailto:james.anderson@setf.de
8 ;;; 'de.setf.amqp' is free software: you can redistribute it and/or modify it under the terms of version 3
9 ;;; of the GNU Affero General Public License as published by the Free Software Foundation.
10 ;;;
11 ;;; 'setf.amqp' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
12 ;;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 ;;; See the Affero General Public License for more details.
14 ;;;
15 ;;; You should have received a copy of the GNU Affero General Public License along with 'de.setf.amqp'.
16 ;;; If not, see the GNU [site](http://www.gnu.org/licenses/).
17
18
19 ;;; to observe the protocol exchange
20 ;;; (setq *log-level* :debug)
21
22 (defparameter *c* (make-instance 'amqp:connection :uri "amqp://guest:guest@localhost/"))
23
24 (amqp:connection-server-properties *c*)
25
26 (amqp:with-open-channel (output *c* :exchange "ex" :type "direct" :queue "q1")
27 (format output "~a, ~a, ~a~%"
28 (lisp-implementation-type)
29 (lisp-implementation-version)
30 amqp.u:*version*))
31
32 (amqp:with-open-channel (input *c* :queue "q1")
33 (read-line input))
34
35
36
37 (amqp:with-open-channel (output *c* :exchange "ex" :type "direct" :queue "q1")
38 (let ((message '("there" "comes" "a" "time" "when" "the" "mind" "takes" "a" "higher" "plane"
39 "of" "knowledge" "but" "can" "never" "prove" "how" "it" "got" "there")))
40 (dotimes (x (- (length message) 4) x)
41 (format output "~d.~{ ~a~}~:[.~;...~]~%" x (subseq message x (+ x 5)) (nth (+ x 5) message)))))
42
43 (amqp:with-open-channel (input *c* :queue "q1")
44 (loop repeat 17 collect (read-line input)))
45
46 ;; a small problem
47
48 (amqp:with-open-channel (input *c* :queue "q1")
49 (loop
50 (unless (print (read-line input nil nil))
51 (return))))

  ViewVC Help
Powered by ViewVC 1.1.5