RSMQ
RSMQ is a lightweight message queue based on Redis.
Setup Redis Server on Docker
Start Redis server on docker:
docker run --name myredis -d redis
-------
A
Connect to the server with:
docker run -it --link myredis:redis --rm redis bash -c 'redis-cli -h redis'
------- ----- -----
A B B
or the full version:
docker run -it --link myredis:redis --rm redis bash -c 'exec redis-cli -h "$REDIS_PORT_6379_TCP_ADDR" -p "$REDIS_PORT_6379_TCP_PORT"'
.
Now in redis console, use info
to get the server's version;
keys *
to list all keys;
set mykey "hello"
to add a key/value pair.
get mykey
to fetch the key's value.
Note:
- Names labled with "A" is the container's name of Redis server. Names labled with "B" is the name alias of Redis server container used by Redis client container.
Setup Redis on Metal Host
Install Redis on Ubuntu 14.04 with:
apt-get install -y python-software-properties # optional
add-apt-repository -y ppa:rwky/redis
apt-get update
apt-get install -y redis-server
Install rsmq: in project root folder, runnpm install rsmq
;
Install rsmq-cli: npm install -g rsmq-cli
;
rsmq config ls
rsmq create -q payment // create a new queue named "payment"
rsmq ls // list all queues
rsmq stats -q payment // print stats of queue "payment"
rsmq send "pay $1000" -q payment // send a message to "payment"
rsmq receive -q payment // receive a message from "payment"