基于 Redis 的消息队列:rmq
jopen
11年前
rmq (Redis Message Queue)
rmq 是一个小型和非常易于使用,基于 Redis 的消息队列 .
rmq 使用 Jedis 作为 Redis 客户端.
rmq目标是成为一个快速,可靠的消息队列.
使用方法:
To use it just as a producer:
Producer p = new Producer(new Jedis("localhost"),"some cool topic"); p.publish("some cool message");
To use it just as a consumer you can consume messages as they become available (this will block if there are no new messages):
Consumer c = new Consumer(new Jedis("localhost"),"consumer identifier","some cool topic"); c.consume(new Callback() { public void onMessage(String message) { //do something here with the message } });
消耗一个等待消息并立即返回:
Consumer c = new Consumer(new Jedis("localhost"),"consumer identifier","some cool topic"); String message = c.consume();
读取下一个消息而不从队列中移除它:
Consumer c = new Consumer(new Jedis("localhost"),"consumer identifier","some cool topic"); String message = c.read();