Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robatron/msgq
A simple "message queue" web-based utility.
https://github.com/robatron/msgq
Last synced: about 2 months ago
JSON representation
A simple "message queue" web-based utility.
- Host: GitHub
- URL: https://github.com/robatron/msgq
- Owner: robatron
- License: gpl-2.0
- Created: 2010-11-09T04:51:55.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2012-07-01T00:00:04.000Z (over 12 years ago)
- Last Synced: 2024-10-19T01:09:12.187Z (3 months ago)
- Language: Python
- Homepage: http://robmd.net:8080
- Size: 128 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MsgQ
MsgQ is short for "Message Queue". It is a simple, web-based utility that allows one to push and pop messages off of a queue. There is also an optional blocking mechanism that allows the server to act "busy" while waiting for a message. This is handy for (almost) instant server-to-client communication.
This is based on the idea of the [messenger component](http://trac.osuosl.org/git/?p=touchscreen.git;a=blob_plain;f=core/messenger.tac;hb=c60491d32feb22ade5aa6abc6bbf925c12c3f427) of the [Touchscreen project](http://trac.osuosl.org/trac/touchscreen).
## Installation
First, `cd` into a directory of your choice, and download the MsgQ source
cd /path/to/installation/directory
git clone git://github.com/robatron/MsgQ.git`cd` into the MsgQ directory, and copy the distributed config file to a working config file
cd MsgQ
cp msgq-serv.config.dist msgq-serv.configInstall Python and CherryPy. If you're on Ubuntu (like me), you should be able to install both with the following:
sudo apt-get install python-cherypy3
Dependencies:
- Python >= v2.6.5
- CherryPy >= v3.1.2## Server-side setup
To start MsgQ, just run
python msgq-serv.py
## Client-side usage
Here are some example uses for MsgQ on the client side:
### Push
To push a message onto a queue, first specify the `queue`, and set `msg` to your message. In the following example, we're pushing a message "O HAI!!" onto the queue "fooQ":
http://localhost:8080/push?queue=fooQ&msg=O HAI!!
If the queue does not exist, it will be created. If the message is not set, or some other error occurs, the error will be returned. If everything went well, a '0' will be returned.
### Pop
To pop a message off of a queue, you only need to specify the `queue`. In the following example, we're popping a message of the "fooQ" queue:
http://localhost:8080/pop?queue=fooQ
The top message on the specified queue will be returned. Trying to pop a message off of an empty queue will result in a "{{empty queue}}" being returned.
Optionally, you can make MsgQ wait for a message to be placed on the queue. This will cause MsgQ to look "busy" to the client while it waits. This is handy for (almost) instant server-to-client communication. Make MsgQ wait by setting the `wait` parameter to the number of milliseconds the queue should wait before it times out, and reports "{{empty queue}}".
In the following example, MsgQ will wait for 5 seconds:
http://localhost:8080/pop?queue=fooQ&wait=5000
If a message gets placed on the queue while it's waiting, MsgQ will return with it right away. If no message gets placed on the queue before the wait time is up, it will return with an "{{empty queue}}".
**Note:** Setting `wait` to a negative number will result in it waiting indefinitely.
### Demo
You can try an [interactive demo](http://robmd.net:8080), or you can try the demo on your own installation by starting the server and going to `/demo`
http://localhost:8080/demo