OPQ - 一款开源高性能持久化消息队列

OPQ

AnOpen sourcedPersistent messageQueue

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

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • cURL是一个利用URL语法规定来传输文件和数据的工具,支持很多协议和选项,如HTTP、FTP、TELNET等,能...
    你很闹i阅读 382评论 0赞 1
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 137,187评论 19赞 139
  • 海峰老师说:你走我不送,因为我知道你离开的时候比来时好;你来,风里雨里我来接你,来或者不来,我都在这里。 参加了一...
    原来是hanNah阅读 256评论 0赞 0
  • 很多年少时候让我们觉得很开心的事后来再想起,只觉得唏嘘不已。 在我的记忆里,初中以前家里都比较贫苦,“三月不知肉味...
    击缶者阅读 462评论 3赞 4
  • 根据数据库中原有的数据结构设计出用户评论的数据结构 之前邱和优优一起总结了一篇研究NodeBB发布一个topic数...
    恐怕是小珠桃子阅读 746评论 0赞 2

友情链接更多精彩内容