@@ -47,7 +47,9 @@ RabbitMQ, and messaging in general, uses some jargon.
47
47
Note that the producer, consumer, and broker do not have to reside on
48
48
the same machine; indeed in most applications they don't.
49
49
50
- ## "Hello World"
50
+
51
+ ## "Hello World"
52
+
51
53
### (using the cl-bunny Common Lisp Client)
52
54
53
55
In this part of the tutorial we'll write two small programs in Lisp; a
@@ -66,7 +68,7 @@ on behalf of the consumer.
66
68
> RabbitMQ speaks AMQP 0.9.1, which is an open,
67
69
> general-purpose protocol for messaging. There are a number of clients
68
70
> for RabbitMQ in [ many different
69
- > languages] ( /devtools.html ) . We'll
71
+ > languages] ( http://www.rabbitmq.com /devtools.html) . We'll
70
72
> use the cl-bunny client in this tutorial.
71
73
>
72
74
> First, install cl-bunny using [ official webpage] ( http://cl-rabbit.io/cl-bunny )
@@ -117,11 +119,11 @@ things done resides:
117
119
To send, we must declare a queue for us to send to; then we can publish a message
118
120
to the queue:
119
121
120
- (with-connection ("amqp://")
121
- (with-channel ()
122
- (let ((x (default-exchange)))
123
- (publish x "Hello world!" : routing-key "hello")
124
- (format t " [ x] Sent 'Hello World!'~ %"))))
122
+ (with-connection ("amqp://")
123
+ (with-channel ()
124
+ (let ((x (default-exchange)))
125
+ (publish x "Hello world!" :routing-key "hello")
126
+ (format t " [x] Sent 'Hello World!'~%"))))
125
127
126
128
Declaring a queue is idempotent - it will only be created if it doesn't
127
129
exist already. The message content is a byte array, so you can encode
@@ -177,15 +179,15 @@ queue. Since it will push us messages asynchronously, we provide a
177
179
callback that will be executed when RabbitMQ pushes messages to
178
180
our consumer. This is what ` subscribe ` does.
179
181
180
- (with-connection ("amqp://")
181
- (with-channel ()
182
- (let ((q (queue.declare "hello" : auto-delete t)))
183
- (format t " [ * ] Waiting for messages in queue 'hello'. To exit type (exit)~ %")
184
- (subscribe q (lambda (message)
185
- (let ((body (babel: octets-to-string (message-body message))))
186
- (format t " [ x] Received ~ a~ %" body)))
187
- : type : sync )
188
- (consume : one-shot t))))
182
+ (with-connection ("amqp://")
183
+ (with-channel ()
184
+ (let ((q (queue.declare "hello" :auto-delete t)))
185
+ (format t " [*] Waiting for messages in queue 'hello'. To exit type (exit)~%")
186
+ (subscribe q (lambda (message)
187
+ (let ((body (babel:octets-to-string (message-body message))))
188
+ (format t " [x] Received ~a~%" body)))
189
+ :type :sync)
190
+ (consume :one-shot t))))
189
191
190
192
` subscribe ` is used with the ` :type :sync ` option that makes it
191
193
block the calling thread (we don't want the script to finish running immediately!).
@@ -210,4 +212,4 @@ If you want to check on the queue, try using `rabbitmqctl list_queues`.
210
212
211
213
Hello World!
212
214
213
- Time to move on to [ part 2] ( tutorial-two-cl.md ) and build a simple _ work queue_ .
215
+ Time to move on to [ part 2] ( tutorial-two-cl.html ) and build a simple _ work queue_ .
0 commit comments