基于 Redis 的消息隊列:rmq

jopen 10年前發布 | 50K 次閱讀 rmq Redis NoSQL數據庫

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();

項目主頁:http://www.baiduhome.net/lib/view/home/1389940417539

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!