AMQP for Lua
I've just released the first version of amqp.lua, a set of LuaJIT bindings for librabbitmq. This code makes it significantly easier to connect Lua programs to each other over a distributed network, all backed with AMQP providing a cross language interoperable message queuing infrastructure. One of the reasons
that I'm releasing this code under a BSD License is so that more Lua programmers look at it as a viable option when wiring together both applications and games. Making applications AMQP aware will make it easier for a wide range of services to be
made available over the internet for general consumption.
For the initial release I put together a very simple utility to send messages to an exchange with a given routing key (currently only connects to localhost as guest, but it is perfectly serviceable for demos):
It is about as trivial as an example that can do something terribly useful. By specifying an exchange, a routing key, and a message, it can send a plain/text message to any consumer willing to consume off of the RabbitMQ instance on my localhost. In a production environment, I would add additional code for random reconnects to a cluster of RabbitMQ servers, and add additional error checking in case something failed, but that is mostly just hardening code common to most applications. Currently,
I'm just using it to test AMQP messaging in the next generation of Jawas, which I will be releasing once the Linux backport is finished. Back in October of 2009, I had embedded Lua in the main
development branch of the Jawas code base, and relied heavily on LuaJIT ever since. Now that I'm adding WebSocket (RFC6455) and AMQP support to Jawas, I found it particularly useful to drive it via a Lua interface. I will likely expose most of my Lua
powered applications' internal APIs to an AMQP based RPC method call system, passing S-expressions to be evaluated as either JSON or Lua tables.
So in any event. Enjoy... This is a very early release (tag 0.0.2) and will likely see some significant API additions in the coming days as I build out some sample consumer applications, and demonstrate some very fun things you can do with Lua and
PostgreSQL stored procedures.