GithubHelp home page GithubHelp logo

amqp-client's Introduction

AMQP Client

Lua Client for AMQP 0.9.1. This library is already tested with RabbitMQ and should work with any other AMQP 0.9.1 broker.

It is a fork of :

This library can be used with LuaJIT and does not have to be used only in OpenResty.

Usage

As this library is already published at Luarocks, you can use this through following command:

luarocks install amqp-client

then, follow this Wiki Documentation to know how to use this library.

Develop

To facilitate to create the lua development environment, was created a Lua Vagrant Image. Use it to gain time.

Case you already have your environment done, just clone this repository and start working. Other else, execute the following steps (Vagrant need to be installed)

Prepare the Environmen

First of all you need to clone the lua-vagrant environment executing this command:

git clone https://github.com/gsdenys/vagrant-lua.git
cd vagrant-lua

As we'll install the RabbitMQ, is very interesting expose the ports to be accessed through the host, this way we can easilly access the administrator enviromnent in your browser. So, to to this, you need to locate the code below at the Vagrantfile

###
# add the network fowarded port here
# ex: config.vm.network "forwarded_port", guest: 15672, host: 8080
###
  
# config.vm.network "forwarded_port", guest: 8080, host: 8080

and insert the the next 2 lines after that:

config.vm.network "forwarded_port", guest: 15672, host: 8080
config.vm.network "forwarded_port", guest: 672, host: 672

So, let's clone this repository inside lua-vagrant project and start it.

git clone https://github.com/gsdenys/amqp-client.git

vagrant up #it takes a lot of time 
vagrant ssh

Now, you already are inside the lua-vagrant VM. Then you need to install the RabbitMQ.

#install RabbitMQ
wget https://bit.ly/2Ycybe8 -O install.sh
sh install.sh

Your environment is ready now. the amqp-client project is in the /lua/amqp-client directory. Go to the project and start to use it.

#go to amqp-client source code
cd /lua/amqp-client

Building

This library have some requirements shown below. If you're using the Lua Vagrant Image just take care about the busted lib, the others is already done.

  1. LuaJIT >= 2.1
  2. busted 2.0 (Testing framework)
  3. luabitop (if you are using lua 5.1)

To install busted lib >= 2.1 execute the following command:

luarocks install busted

This library can use cqueues; once cqueues is installed the library automatically starts to use it. to install cqueues use this command.

luarocks install cqueues

case you don't want to use cqueues you need to use the lua socket. Install it with this command:

luarocks install luasocket

After requirements solved, you can run the unit tests with busted using the following command:

busted

Wow you are ready to build the library executing following command::

luarocks make

the output should be like this:

amqp-client 1.0.0-1 is now installed in /usr/local (license: Apache 2.0)

Examples

The examples needs some dependencies that can be solved through the following commands:

luarocks install inspect
luarocks install lua-resty-uuid
luarocks install argparse

Beyond dependences, the examples depends on build of this library. Other way to execute the examples less building the library is import this library from luarocks. You can do this executing this command.

luarocks install amqp-client

amqp-client's People

Contributors

4mig4 avatar cb57446 avatar cybermaggedon avatar gsdenys avatar imolein avatar zigzagak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

amqp-client's Issues

Add Sonar

Add this project to a sonar to check the code quality

Refectory the init.lua

Refectory the code hiding the method unusual like amp:consume_loop() [used by amqp:consume()] - this method, as many others, should be local once they do the same thing that others.

general questions

Hello,

I've been playing with LUA with openresty and its great so far.

I would have few question please:

  • does amqp-client ha ve a 100% nonblocking behavior ?
  • could please advise in which context is it best to use ? ( init_by_lua_* , content_by_lua_* ) ?
  • is it possible to "use" it in the background ? Meaning that the connection never dies unless the client get disconnected by the amqp server ?

To give you some context, in my case I would like to use it only as a consumer to create / delete / update keys in a local redis ( using resty.redis ) independently of traffic / user request.

Meaning that the amqp client connection should be persistant and keep interacting with the local redis.

Basically, Im wondering if I could replace one of my micro service using nodejs / amqp by openresty / amqp-client.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.