OPQ - 開源持久化訊息佇列

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

OPQ

  • An Open sourced Persistent message Queue

  • Code is tested under go1.4.2, higher version should be OK (CAUTION: OPQ hasn't been tested in production environment so far)

Features

  1. persistent message storage

  2. push model - push message to target service and block when failure

  3. easy to use - simple API whith HTTP POST method, no addtional client integration is required

  4. message replay

  5. high performance aimed

  6. operations-friendly - graceful stop/restart, HA (TODO)

Performance

  1. over 20,000(Message/Second) with 2K(Byte) message payload

  2. over 30,000(Message/Second) with 1K(Byte) message payload

Install

Download source code

go get -u github.com/LevinLin/OPQ

Build OPQ

cd /path/to/OPQgo build

Run OPQ

cd /path/to/OPQnohup ./OPQ &>/dev/null &

-debug

System runs in debug model when given debug=yes, which will enable
log/output in debug level, default to no

-port

Listening port, default to 8999

-syslog

System log name, default to system.log

-admin

Enable admin portal when given admin=yes, default to no (TODO, not
available yet)

Gracefully restart OPQ

kill -1 %{PID}

Usage

Push Message

url:
http://%{SERVER_NAME}[:%{SERVER_PORT}]/opq/push

post fields:

  1. url: target url

  2. topic: each message should belong to a topic

  3. message: message content

header: specify the header if you need

example:(PHP)

<?php  $url = "http://localhost:8999/opq/push";    $ch = curl_init();  curl_setopt($ch, CURLOPT_URL, $url);  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  curl_setopt($ch, CURLOPT_POST, 1);  $data = array(      'url' => 'http://127.0.0.1/Comment/addComment?comment=nny&user=q18',      'topic'=> 'comment',      'message'=> 'this is message body',  );  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);  $response = curl_exec($ch);  var_dump($response);  curl_close($ch);

Replay Message

url:
http://%{SERVER_NAME}[:%{SERVER_PORT}]/opq/replay

post fields:

  1. topic: topic name

  2. cmd: commond number (message index, start from 0)

example:(PHP)

<?php  $url = "http://localhost:8999/opq/replay";  $ch = curl_init();  curl_setopt($ch, CURLOPT_URL, $url);  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);   curl_setopt($ch, CURLOPT_POST, 1);     $data = array(      'topic'=> 'comment',      'cmd'=> '30',  );    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);  $response = curl_exec($ch);  var_dump($response);  curl_close($ch);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.