This is a creation in Article, where the information may have evolved or changed.
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
Persistent message storage
push Model-push message to target service and block when failure
Easy-to-use-simple API whith HTTP POST method, no addtional client integration is required
Message Replay
High performance aimed
operations-friendly -Graceful Stop/restart, HA (TODO)
Performance
Over 20,000(Message/second) with 2K(Byte) Message payload
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'll 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
postfields:
URL: Target URL
Topic: Each message should belong to a topic
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
postfields:
topic: Topic name
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);