/[de-setf-amqp]/readmes/example-publish-get-loop.lisp
ViewVC logotype

Contents of /readmes/example-publish-get-loop.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Tue Feb 23 09:05:39 2010 UTC (4 years, 2 months ago) by janderson
File size: 2574 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 examples of use of 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 ;;; If you received this together with an MC image, place that image in a directory together with the MCL
19 ;;; [kernel](ftp://ftp.clozure.com/pub/MCL/MCL-5.2-Final3.dmg) and double-click it.
20
21
22 (defun publish-get-loop (publish-channel get-channel data count
23 &key (queue "q1") (exchange "ex")
24 (routing-key "/")
25 ;; specify :debug to observe the protocol exchange
26 ((:log-level *log-level*) *log-level*))
27 (let* ((publish-basic (amqp:basic publish-channel))
28 (get-basic (amqp:basic get-channel))
29 (exchange (amqp:exchange publish-channel :exchange exchange :type "direct"))
30 (publish-queue (amqp:queue publish-channel :queue queue))
31 (get-queue (amqp:queue get-channel :queue queue)))
32
33 (amqp:request-declare publish-queue)
34 (amqp:request-declare get-queue)
35 (amqp:request-bind publish-queue :exchange exchange :queue publish-queue :routing-key routing-key)
36
37 (dotimes (i count)
38 (dolist (datum data)
39 (amqp:request-publish publish-basic :exchange exchange :body datum :routing-key routing-key)
40 (amqp:request-get get-basic :queue get-queue)))))
41
42
43 (defparameter *c* (make-instance 'amqp:connection :uri "amqp://guest:guest@localhost/"))
44 (defparameter *ch1* (amqp:channel *c* :uri (uri "amqp:/")))
45 (defparameter *ch2* (amqp:channel *c* :uri (uri "amqp:/")))
46
47 (publish-get-loop *ch1* *ch2* '("this is a test") 1)
48
49 ;;; (time (publish-get-loop *ch1* *ch2* '("a") 10000))
50
51 ;;; os x, g5-2.5g, qpid-0.5
52 ;;; sbcl : 52 seconds, 154 MB
53 ;;; mcl : 120 seconds, 11 MB
54 ;;; ccl : 52 seconds, 17.8 MB

  ViewVC Help
Powered by ViewVC 1.1.5