• Stars
    star
    555
  • Rank 80,213 (Top 2 %)
  • Language
    Python
  • Created about 15 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

REST/JSON/HTTP based message queue

RESTMQ

Redis based message queue.

Info:See RestMQ website
Info:See my blog <http://blog.7co.cc> for more information.
Author: Gleicon Moraes <http://github.com/gleicon>
Author: Alexandre Fiori

About

RestMQ is a message queue which uses HTTP as transport, JSON to format a minimalist protocol and is organized as REST resources. It stands on the shoulder of giants, built over Python, Twisted, Cyclone (a Tornado implementation over twisted) and Redis.

Redis is more than just a key/value db, and its data types provided support for this project.

Queues are created on the fly, when a message is sent to them. They are simple to use as a curl request can be. HTTP Comet, websockets and server sent events may be used for data streaming.

This release is a cleanup of the original code, that can also be found on github.

Install

$ python setup.py install run with bash start_scripts/restmq_server or taylor your own script. Note that currently restmq is presented as a twisted plugin.

Alternatively you can utilize [Vagrant](https://www.vagrantup.com/) and our [Vagrantfile](Vagrantfile) which will handle installation and configuration of redis and RestMQ.

Another option is to run the project inside a docker container:

` docker build -t restmq . docker run --rm -p 6379:6379 -p 8888:8888 restmq `

It will run restmq, exposing both 8888 (for its http port) and 6379 (for its redis server) to the host environment.

Queue Policy

Every queue is created with a default policy, which is broadcast. It means that each message pushed to a queue will be forwarded to all comet and websocket consumers.

The alternative policy is roundrobin, which will distribute these messages in a round robin fashion to all comet and websocket consumers.

The queue policy won't affect regular GET commands to pop a single message from a queue.

See README.qp for details.

Queue Flow Control

Yes, it does support start and stop. We just need to document it properly.

Example

A http client (curl) post to /queue:

Point your browser to http://localhost:8888/c/test

Run $ curl -d "queue=test&value=foobar" http://localhost:8888/

Your browser is acting as a consumer to the queue. Using json encoded data it's easy to fit the data into a js based app.

Aside from the COMET consumer, there are xmlrpc methods, rest routes and the JSON protocol to manipulate queue items.

COMET consumer

There is a COMET based consumer, which will bind even if the queue doesn't already exists.

The main route is thru /c/<queuename>. It can be tested using curl:

$ curl http://localhost:8888/c/test

In another terminal, run $ curl -d "value=foobar" http://localhost:8888/q/test

This is the basic usage pattern for map/reduce (see examples).

See below on how to purge and disconnect all consumers from a queue, using DELETE.

WebSocket consumer

Now that cyclone has websockets support, check README.websocket to test it.

If you are using a browser or library which already supports websockets, you may take advantage of this interface.

REST services

A queue can be accessed as /q/<queuename>.

GET requests will dequeue an object.

POST requests inserts an object in the queue

DELETE requests will purgue the queue.

The usual pattern is listen in the COMET consumer (/c/<queuename>) and insert new stuff at the REST route (POST /q/<queuename).

JSON Protocol

The HTTP route /queue/<queuename> uses the JSON protocol. Its the same protocol I've implemented for http://jsonqueue.appspot.com.

{
    "cmd": "add",
    "queue": "genesis",
    "value": "abacab"
}

Creates the queue named "genesis" and inserts the string "abacab" as the message.

If we want to take that out of the queue, the payload would be like that:

{
    "cmd": "take",
    "queue": "genesis"
}

The message can be formatted as a json object, so more complex data can be sent. It really mimics some of Amazon SQS workings, because it's a simple queue.

For the first release it has:

  • Select, EPoll or KQueue concurrency (depends on twisted)
  • Persistent storage using Redis
  • Can work on pools, N daemons consuming from the same queues.
  • Small codebase
  • Lightweight
  • Cute ?

Dependencies

  • cyclone: git clone git://github.com/fiorix/cyclone.git

Running

The redis_server script will start the service. It's a bash script used to both configure and run RestMQ. The default version of the wrapper script will run the server in foreground, and log messages will be written to the standard output.

Editing the script is mandatory for configuring RestMQ for production.

$ ./restmq_server --help
Usage: twistd [options] restmq [options]
Options:
      --acl=         acl configuration file for endpoints [default: acl.conf]
      --redis-host=  hostname or ip address of the redis server [default: 127.0.0.1]
      --redis-port=  port number of the redis server [default: 6379]
      --redis-pool=  connection pool size [default: 10]
      --port=        port number to listen on [default: 8888]
      --listen=      interface to listen on [default: 127.0.0.1]
      --version
      --help         Display this help and exit.

Tests

examples/test_rest.sh
examples/test_xmlrpc.py
python examples/test_comet.py
python examples/twitter_trends.py
python examples/test_comet_curl.py
python restmq_engine.py -h

Files

If you're a developer looking for extending RestMQ's functionality, have a look at these files:

Credits

Thanks to (in no particular order):

  • Salvatore Sanfilippo for redis and for NoSQL patterns discussion.
  • Alexandre Fiori for the redis client enhancement and patches.
  • Roberto Gaiser for the collectd daemon
  • Vitor Pellegrino for dockerizing restmq

More Repositories

1

python-uurl

url shortener using bottle, redis and gevent
Python
82
star
2

ebook_cto_field_guide

The CTO Field Guide
Dockerfile
76
star
3

beano

kv database that speaks memcached and can switch dataset gracefully on the fly for batch loading
Go
42
star
4

txwebsockets

Twisted Server Protocol for websockets
Python
34
star
5

locust-swarm

ansible automation to master/slave locust.io test
Python
31
star
6

caixa-de-ferramentas-devops

Repositรณrio de cรณdigo para o livro caixa de ferramentas devops
Python
28
star
7

go-beacon

HTTP Beacon for boomerang.js and other analytics/trackers
Go
24
star
8

pyriemann

Python client for Riemann
Python
20
star
9

pasteme

a pastebin clone written in python, using bottle and mongodb
Python
19
star
10

ebook-go-sketch

Ebook sobre Go e estruturas de dados probabilisticas
Go
19
star
11

habitat

habitat is a coreutils 'env' clone to link 12factor apps and service discovery systems as consul and etcd. It queries the kv db embedded in those systems and export the data as env variables. If you don't use etcd or consul, there's a redis module to capture data from a hash.
Go
18
star
12

pymetrics

metrics for python
Python
17
star
13

tinymq

Minimal RestMQ implementations in a single place
Ruby
16
star
14

py_descriptive_statistics

port of ruby's descriptive statistics to python
Python
15
star
15

python_dns_servers

gevent and twisted based customizable DNS servers
Python
14
star
16

pubsub_ws

pubsub using node.js, redis and websockets
JavaScript
12
star
17

docdb

Musings and tests on NoSQL/Document based DBs using Redis
Python
12
star
18

pipecamp

Command line to manage your local docs
Go
11
star
19

mure

python actor framework
Python
11
star
20

uurl-mongodb

url shortener using redis and mongodb
JavaScript
10
star
21

editor.js

node.js and diff patch match based multi user text editor (proof of concept)
JavaScript
10
star
22

zenmachine

zenmachine.wordpress.com code repo
Python
10
star
23

ts-cli

A timeseries command line interface to help you count and measure stuff.
Go
9
star
24

docker-cookbook

dotcloud's docker chef recipe/cookbook w/ nginx
Ruby
8
star
25

pasteit

pastebin clone built with python, gevent, bottle, pygments
JavaScript
8
star
26

vagrant-influxdb-grafana

vagrant and ansible setup for influxdb and grafana
JavaScript
7
star
27

go-restmq

Go port of restmq
Go
6
star
28

nodester_pubsub

Pub/Sub over http for the nodester PaaS
JavaScript
6
star
29

refluxdb

rust timeseries db
Rust
6
star
30

sentiment_analysis

tools for sentiment analysis
Python
6
star
31

nazare

when you have to approximately count a lot of things...
Go
6
star
32

parquet-explorer

parquet file explorer w/ rust and arrow
Rust
5
star
33

leveldb_engine

memcached leveldb engine - stores data on leveldb
C
5
star
34

swarm

Distributed EventEmitter for Golang
Go
5
star
35

dados-sp

Dados retirados do IBGE e alguns scripts para manipulaรงรฃo e sumarizaรงรฃo
Python
5
star
36

gasket

(m)tls proxy entrypoint for containers
Rust
4
star
37

go-eventemitter

EventEmitter for Go
Go
4
star
38

lerolero

gerador de lero lero de 19xx adaptado para a nuvem da web TI 3.0
JavaScript
4
star
39

memcached-cli

redis-cli inspired memcached client
Go
4
star
40

cronitor

single binary simple http monitor to run on crontab. sends email and slack notification
Go
4
star
41

kafka-shell

golang shell utilities for kafka
Go
4
star
42

txmetrics

Redis backed metrics (counters, gauges, histogram and timers) for twisted apps
Python
4
star
43

gongout

golang simplewebrtc videochat demo
CSS
4
star
44

gong

golang + mysql + httpauth + sbadmin boilerplate
HTML
4
star
45

pubsub_comet

Pub/Sub using Redis, Node.js and COMET as transport - work in progress
JavaScript
3
star
46

comet_ws_proxy

WebSocket proxy for COMET using node.js
JavaScript
3
star
47

go-descriptive-statistics

Port of https://github.com/thirtysixthspan/descriptive_statistics to Go
Go
3
star
48

restmq_websockets

Example on how to use/deploy restmq websockets endpoint on a web app.
Python
3
star
49

pasteme-erl

PasteME written in Erlang using mochiweb, redis, mongodb and editarea
Erlang
3
star
50

uurl-erl

URL Shortener using Erlang, Mochiweb, Redis and MongoDB
Erlang
3
star
51

golang_http_api_skel

skeleton for a golang api template
Go
2
star
52

memcached_fs_engine

memcached engine exercise from trondn - writes and reads values from the filesystem
C
2
star
53

vagrant-ansible-computervision

vagrant and ansible setups for computer vision
2
star
54

pubsub_cfoundry

pubsub for cloud foundry using node.js
JavaScript
2
star
55

restmq-rs

Rust port of restmq - the restful message broker (http://restmq.com/)
Rust
2
star
56

memcached_redis_engine

redis based memcached backend
C
2
star
57

MacOSThemeDetector

A statusbar/agent app to detect and react to theme changes.
Swift
2
star
58

gitto

gitto is a github and travis-ci webhook handler with configurable actions to ease deployment and sync of repositories.
Go
2
star
59

hatch

k8s uperator written in rust + gasket proxy ingress (hopefully)
Rust
2
star
60

3s

s3 prototype using cyclone and other cool stuff
Python
2
star
61

arpmonitor

repo for arpmonitor
C
2
star
62

pubsub

http comet pubsub with channels in go exercise
Go
2
star
63

jruby-sinatra-tomcat-sqlite-example

sample jruby/sinatra/sqlite/tomcat or any other container app
Ruby
2
star
64

baseline_bootstrap_node_express_passport

basic app with node, express, mongodb, passport, bootstrap
JavaScript
2
star
65

apex_loadtest

Apex, AWS Lambda and Golang loadtesting brain dump
Go
2
star
66

archive

old code and projects, circa 1998/2000. funny to see them.
C
2
star
67

restmq-erl

Port of RestMQ to Erlang
Erlang
2
star
68

heroku_postsub

pubsub for heroku using comet and server sent events
JavaScript
2
star
69

vagrant-ansible-cloud9

Vagrant and ansible setup to install cloud9 locally or remotely
2
star
70

lemmy

Opinionated loadbalancer and API gateway
Go
2
star
71

proglinux

Code samples from my first book
C
1
star
72

homebrew_recipes

My homebrew recipes
Ruby
1
star
73

insertjs

Inserts something into a HTML doc
JavaScript
1
star
74

go-vuvuzela

enable vuvuzela at any website.
Go
1
star
75

certificate

Bunch of scripts that I've used to create Certification for my talk at IgniteSP
JavaScript
1
star
76

goper

goper is a hoper clone. tracks urls redirects and so on.
Go
1
star
77

ebook_template

book template with md to pdf generator
Dockerfile
1
star
78

bloodpressure_timeseries

bloodpressure time series api with golang and boltdb
Go
1
star
79

wharf

linux containers automation framework
Shell
1
star
80

videodog

video capture and processing on linux using v4l
C
1
star
81

go-httplogger

Apache commonlog format for golang
Go
1
star
82

tosco-shell

ancient shell /* (c) 1999 gleicon, alex fiori */
C
1
star
83

gleicon.github.io

blog
CSS
1
star
84

slideshow

remote slideshow using reveal.js
JavaScript
1
star
85

engino

NGINX configuration manager that dynamically gets data from etcd/consul/redis, create vhost configs using templates and other goodies.
Go
1
star
86

baseline_bootstrap

baseline bootstrap, css and js repo
1
star
87

mqttail

Mqtt tail client
Go
1
star
88

tx-memcached-redis

experimental memcached daemon backed by redis
Python
1
star
89

morocco

Modular search
Rust
1
star
90

go-pruning-radix-trie

Go implementation of Pruning Radix Trie, algorithm by Wolf Garbe
1
star
91

vuvuzelr

code from vuvuzelr
Ruby
1
star
92

ron_swanson_bot

Ron Swanson's recipe for greatness and a python/gevent/bottle/APScheduler bot to run locally or heroku
JavaScript
1
star
93

restmq-appengine

Rest Message Queue using JSON as protocol and HTTP as transport, appengine version
Python
1
star