This is a creation in Article, where the information may have evolved or changed.
Https://github.com/LevinLin/OPQ
OPQ
- An Open sourced persistent message Queue
- Code is tested under go1.4.2 (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'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)
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);
909 Reads