a lua wrapper of the C++ RabbitMQ AMQP client library wrapper SimpleAmqpClient written mostly on a subway train
many features work, but just as the SimpleAmqpClient tests are failing, so are the wrapper tests.
semi-abandoned
The api is mirroring the c++ api as closely as possible. Some overloads are split into multiple functions. To read the full documentation, please refer to the original documentation in SimpleAmqpClient. The full binding can be seen at a glance in luconejo_lib.cpp -> register_luconejo See the tests for the API usage examples
luconejo.version
luconejo version string
luconejo.client_version
SimpleAmqpClient version
luconejo.amqp_version()
rabbitmq-c version string
connection = luconejo.Channel.Create( host ) -- create a connection (simple api)
connection = luconejo.Channel.CreateWithParameters(
host,
port,
username,
password,
vhost,
frame_max)
connection = luconejo.Channel.CreateFromUri( host_uri ) -- connect with an AMQP URI
connection.Valid -- check if connection succeeded
luconejo.Channel.EXCHANGE_TYPE_DIRECT -- constant
luconejo.Channel.EXCHANGE_TYPE_FANOUT -- constant
luconejo.Channel.EXCHANGE_TYPE_TOPIC -- constant
connection:SimpleDeclareExchange(exchange_name)
connection:DeclareExchange(
exchange_name,
exchange_type,
passive,
durable,
auto_delete)
connection:DeleteExchange( exchange_name )
connection:DeleteExchangeIfUnused( exchange_name )
connection:BindExchange( destination, source, routing key )
connection:UnbindExchange( destination, source, routing key )
local queue_name = connection:SimpleDeclareQueue( queue_name )
local queue_name = connection:DeclareQueue(
queue_name,
passive,
durable,
exclusive,
auto_delete)
-- returns luconejo.Channel.INVALID_QUEUE_NAME if failed
connection:BindQueue( queue_name, exchange_name, routing_key )
connection:UnbindQueue( queue_name, exchange_name, routing_key )
connection:PurgeQueue( queue_name )
connection:DeleteQueue( queue_name, if_unused, if_empty )
connection:Disconnect()
message = luconejo.BasicMessage.Create( body )
create a message with a string-body
local body = message.Body` get the message text
connection:BasicPublish(exchange_name, routing key, message, mandatory, immediate)
message should be a luconejo.BasicMessage
.
connection:SimpleBasicPublish(exchange_name, routing key, message)
nonmandatory and not immediate.
local consumer_tag = connection:SimpleBasicConsume(queue)
local consumer_tag = connection:BasicConsume(
queue,
consumer_tag,
no_local,
no_ack,
exclusive,
prefetch_count) -- returns the consumer tag
local envelope = connection:BasicConsumeMessage(consumer_tag,timeout)
local envelope = connection:BasicGet( queue, no_ack )
local message = envelope.Message
returns luconejo.BasicMessage
connection:BasicCancel( consumer_tag )
stop consuming
connection:BasicAck(envelope)
where envelope
is luconejo.Envelope
connection:BasicRecover( consumer )
connection:BasicQos( consumer, message_prefetch_count )
Currently, the wrapped objects have a .Valid
property, indicating if the object has been successfully created.
If not valid, the object ignores commands.
The exception text is sent to stderr
.
void (...)
methods return true
if succeeded or false
if exception thrown.
All parameters are mandatory at the moment. C++ Function signatures with default values or without are mapped onto different Lua functions.
- generate your makefiles or project files using premake
- on Linux and MacOS X the rabbitmq-c library can be built and installed using
premake4 prepare
- build accordingly
motivation: Recursive Make Considered Harmful
By way of writing this binding, partially going the wrong way of wrapping an otherwise simpler-bindable class, I can dive into the API and its details.
all dependent libraries are built from source
- rabbitmq-c
- SimpleAmqpClient
- LuaBridge
- Premake for generating makefiles and solutions
- start RabbitMQ
> premake/premake4 test