enlivend (enlivend) wrote,

CL-RABBIT - an interface from LispWorks to RabbitMQ

I am very pleased to announce the release of version 0.1 of CL-RABBIT: an interface from LispWorks via the JFLI to the RabbitMQ implementation of the AMQP messaging protocol.

http://www.nicklevine.org/cl-rabbit/

It's released under an MIT-style license, a copy of which appears in each source file. Many thanks to Wiinz Limited for giving me permission to do all this and I'm sorry it's taken so long to get around to kicking the brute through the door.

Here's how it goes. More details in the readme.

  1. Open a connection and a channel (I'll be lazy and use the same channel for outgoing and incoming messages), declare exchange and queue, bind everything together:

    RABBITMQ 6 > (setf my-connection (new-connection "localhost" "/"))
    #<AMQCONNECTION. amqp://guest@localhost:5672/ 200DCD87>
    
    RABBITMQ 7 > (setf my-channel (new-channel my-connection))
    #<CHANNEL AMQChannel(amqp://guest@localhost:5672/,1) 200F7BB3>
    
    RABBITMQ 8 > (declare-exchange my-channel "my exchange" :direct)
    #<|com.rabbitmq.client.impl|::AMQIMPL$EXCHANGE$DECLAREOK. 2009159F>
    
    RABBITMQ 9 > (declare-queue my-channel "my queue")
    #<|com.rabbitmq.client.impl|::AMQIMPL$QUEUE$DECLAREOK. 21D050CF>
    
    RABBITMQ 10 > (bind-queue my-channel "my queue" "my exchange" "my routing key")
    #<|com.rabbitmq.client.impl|::AMQIMPL$QUEUE$BINDOK. 21CEEFD3>
  2. Send a message into the void:

    RABBITMQ 11 > (setf outgoing-message (new-message))
    #<OUTGOING-MESSAGE 21CE265B>
    
    RABBITMQ 12 > (setf (message-id outgoing-message) "42"
    		    (message-body outgoing-message) "Hello, World")
    "Hello, World"
    
    RABBITMQ 13 > (publish outgoing-message my-channel "my exchange" "my routing key")
    NIL
  3. And get it back again:

    RABBITMQ 14 > (consume-queue my-channel "my queue")
    "amq.ctag1_rabbit@gannet_20090402084407_"
    
    RABBITMQ 15 > (channel-arrived-count my-channel)
    1
    
    RABBITMQ 16 > (setf incoming-message (next-message my-channel))
    #<QUEUEINGCONSUMER$DELIVERY. 200E0E93>
    
    RABBITMQ 17 > (values (message-body incoming-message)
    		      (message-id incoming-message))
    "Hello, World"
    "42"
    
    RABBITMQ 18 >
    Tags: lisp
    • Post a new comment

      Error

      Anonymous comments are disabled in this journal

      default userpic

      Your reply will be screened

    • 0 comments