You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by hooligan520 <gi...@git.apache.org> on 2017/04/17 16:09:22 UTC

[GitHub] incubator-rocketmq-externals pull request #11: [ROCKETMQ-129] Initialized th...

GitHub user hooligan520 opened a pull request:

    https://github.com/apache/incubator-rocketmq-externals/pull/11

    [ROCKETMQ-129] Initialized the rocketmq c++ client 

    see https://issues.apache.org/jira/browse/ROCKETMQ-129 
    for tracking

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/hooligan520/incubator-rocketmq-externals master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-rocketmq-externals/pull/11.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #11
    
----
commit 9cce6e20fa50cde2bdd6cc891acf04d11b4ace6d
Author: hooligan520 <79...@qq.com>
Date:   2017-04-17T13:46:01Z

    Merge pull request #1 from apache/master
    
    merge

commit 7396626b0a3918c4e44a3d9affc3ef62a5767d4f
Author: hooligan520 <79...@qq.com>
Date:   2017-04-17T15:59:11Z

    RocketMQ Gpp Client Init

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals issue #11: [ROCKETMQ-129] Initialized the rocke...

Posted by lizhanhui <gi...@git.apache.org>.
Github user lizhanhui commented on the issue:

    https://github.com/apache/incubator-rocketmq-externals/pull/11
  
    IMO, we should merge this PR ASAP so that we would have an existing code base to get started.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals pull request #11: [ROCKETMQ-129] Initialized th...

Posted by hooligan520 <gi...@git.apache.org>.
Github user hooligan520 commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq-externals/pull/11#discussion_r111866834
  
    --- Diff: rocketmq-client4cpp/example/demo/AsyncProducer.cpp ---
    @@ -0,0 +1,253 @@
    +/**
    +* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
    +*
    +* Licensed under the Apache License, Version 2.0 (the "License");
    +* you may not use this file except in compliance with the License.
    +* You may obtain a copy of the License at
    +*
    +*     http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing, software
    +* distributed under the License is distributed on an "AS IS" BASIS,
    +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +* See the License for the specific language governing permissions and
    +* limitations under the License.
    +*/
    +
    +#include "Common.h"
    +#include "SendCallback.h"
    +#include "DefaultMQProducer.h"
    +using namespace rmq;
    +
    +long long g_lastUpdateTime = 0;
    +volatile long long g_cnt_total = 0;
    +volatile long long g_cnt_last = 0;
    +volatile long long g_cnt_succ = 0;
    +volatile long long g_cnt_fail = 0;
    +
    +
    +void Usage(const char* program)
    +{
    +    printf("Usage:%s ip:port [-g group] [-t topic] [-n count] [-s size] [-w logpath]\n", program);
    +    printf("\t -g group\n");
    +    printf("\t -t topic\n");
    +    printf("\t -n message count\n");
    +    printf("\t -s message size \n");
    +    printf("\t -w log path\n");
    +}
    +
    +
    +class SampleSendCallback : public SendCallback {
    +public:
    +    SampleSendCallback()
    +    {
    +    }
    +
    +    virtual ~SampleSendCallback()
    +    {
    +    }
    +
    +    int count()
    +    {
    +
    +        long long now = MyUtil::getNowMs();
    +        long long old = g_lastUpdateTime;
    +        long long total = g_cnt_succ + g_cnt_fail;
    +        if ((now - old) >= 1000)
    +        {
    +            if (__sync_bool_compare_and_swap(&g_lastUpdateTime, old, now))
    +            {
    +                long long time = now - old;
    +                int tps = (int)((total - g_cnt_last) * 1.0 / time * 1000.0);
    +                g_cnt_last = total;
    +
    +                MYDEBUG("[producer]succ: %lld, fail: %lld, TPS: %d\n",
    +                    g_cnt_succ, g_cnt_fail, tps);
    +            }
    +        }
    +    }
    +
    +    void onSuccess(SendResult& sendResult)
    +    {
    +        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
    +        __sync_fetch_and_add(&g_cnt_succ, 1);
    +        MYLOG("[%d]|succ|%s\n",  cnt, sendResult.toString().c_str());
    +    }
    +
    +    void onException(MQException& e)
    +    {
    +        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
    +        __sync_fetch_and_add(&g_cnt_fail, 1);
    +
    +        MYLOG("[%d]|fail|%s\n",  cnt, e.what());
    +    }
    +};
    +
    +int main(int argc, char *argv[]) {
    +    if (argc < 2)
    +    {
    +        Usage(argv[0]);
    +        return 0;
    +    }
    +
    +    std::string namesrv = argv[1];
    +    std::string group = "pg_test_group";
    +    std::string topic = "topic_test";
    +    int size = 32;
    +    int count = 1000;
    +
    +    for (int i=2; i< argc; i++)
    +    {
    +        if (strcmp(argv[i],"-g")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                group = argv[i+1];
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-t")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                topic = argv[i+1];
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-n")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                count = atoi(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-s")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                size = atoi(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-w")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                MyUtil::initLog(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else
    +        {
    +            Usage(argv[0]);
    +            return 0;
    +        }
    +    }
    +
    --- End diff --
    
    ok\uff0cI will remove all Chinese in the source code


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals issue #11: [ROCKETMQ-129] Initialized the rocke...

Posted by Jothipandiyan-jp1 <gi...@git.apache.org>.
Github user Jothipandiyan-jp1 commented on the issue:

    https://github.com/apache/incubator-rocketmq-externals/pull/11
  
    Is there any plan for releasing c++ windows SDK   in upcoming weeks?
    Is c# SDK is going to release?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals pull request #11: [ROCKETMQ-129] Initialized th...

Posted by lizhanhui <gi...@git.apache.org>.
Github user lizhanhui commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq-externals/pull/11#discussion_r111867144
  
    --- Diff: rocketmq-client4cpp/example/demo/AsyncProducer.cpp ---
    @@ -0,0 +1,253 @@
    +/**
    +* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
    +*
    +* Licensed under the Apache License, Version 2.0 (the "License");
    +* you may not use this file except in compliance with the License.
    +* You may obtain a copy of the License at
    +*
    +*     http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing, software
    +* distributed under the License is distributed on an "AS IS" BASIS,
    +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +* See the License for the specific language governing permissions and
    +* limitations under the License.
    +*/
    +
    +#include "Common.h"
    +#include "SendCallback.h"
    +#include "DefaultMQProducer.h"
    +using namespace rmq;
    +
    +long long g_lastUpdateTime = 0;
    +volatile long long g_cnt_total = 0;
    +volatile long long g_cnt_last = 0;
    +volatile long long g_cnt_succ = 0;
    +volatile long long g_cnt_fail = 0;
    +
    +
    +void Usage(const char* program)
    +{
    +    printf("Usage:%s ip:port [-g group] [-t topic] [-n count] [-s size] [-w logpath]\n", program);
    +    printf("\t -g group\n");
    +    printf("\t -t topic\n");
    +    printf("\t -n message count\n");
    +    printf("\t -s message size \n");
    +    printf("\t -w log path\n");
    +}
    +
    +
    +class SampleSendCallback : public SendCallback {
    +public:
    +    SampleSendCallback()
    +    {
    +    }
    +
    +    virtual ~SampleSendCallback()
    +    {
    +    }
    +
    +    int count()
    +    {
    +
    +        long long now = MyUtil::getNowMs();
    +        long long old = g_lastUpdateTime;
    +        long long total = g_cnt_succ + g_cnt_fail;
    +        if ((now - old) >= 1000)
    +        {
    +            if (__sync_bool_compare_and_swap(&g_lastUpdateTime, old, now))
    +            {
    +                long long time = now - old;
    +                int tps = (int)((total - g_cnt_last) * 1.0 / time * 1000.0);
    +                g_cnt_last = total;
    +
    +                MYDEBUG("[producer]succ: %lld, fail: %lld, TPS: %d\n",
    +                    g_cnt_succ, g_cnt_fail, tps);
    +            }
    +        }
    +    }
    +
    +    void onSuccess(SendResult& sendResult)
    +    {
    +        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
    +        __sync_fetch_and_add(&g_cnt_succ, 1);
    +        MYLOG("[%d]|succ|%s\n",  cnt, sendResult.toString().c_str());
    +    }
    +
    +    void onException(MQException& e)
    +    {
    +        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
    +        __sync_fetch_and_add(&g_cnt_fail, 1);
    +
    +        MYLOG("[%d]|fail|%s\n",  cnt, e.what());
    +    }
    +};
    +
    +int main(int argc, char *argv[]) {
    +    if (argc < 2)
    +    {
    +        Usage(argv[0]);
    +        return 0;
    +    }
    +
    +    std::string namesrv = argv[1];
    +    std::string group = "pg_test_group";
    +    std::string topic = "topic_test";
    +    int size = 32;
    +    int count = 1000;
    +
    +    for (int i=2; i< argc; i++)
    +    {
    +        if (strcmp(argv[i],"-g")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                group = argv[i+1];
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-t")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                topic = argv[i+1];
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-n")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                count = atoi(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-s")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                size = atoi(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-w")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                MyUtil::initLog(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else
    +        {
    +            Usage(argv[0]);
    +            return 0;
    +        }
    +    }
    +
    --- End diff --
    
    IMO, it's also a good idea to create a few JIRA ticks, listing planned tasks. This helps in that 1) we may track development progress; 2) new-joiner may figure out what to do easier; 2) Developers won't repeat work on the same issue.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals issue #11: [ROCKETMQ-129] Initialized the rocke...

Posted by lizhanhui <gi...@git.apache.org>.
Github user lizhanhui commented on the issue:

    https://github.com/apache/incubator-rocketmq-externals/pull/11
  
    @hooligan520 Support for Windows is removed, right? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals issue #11: [ROCKETMQ-129] Initialized the rocke...

Posted by hooligan520 <gi...@git.apache.org>.
Github user hooligan520 commented on the issue:

    https://github.com/apache/incubator-rocketmq-externals/pull/11
  
    @lizhanhui yes\uff0cbecause I only developed in the Linux, so remove the support for windows,  I will re-merged back in the future


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals pull request #11: [ROCKETMQ-129] Initialized th...

Posted by lizhanhui <gi...@git.apache.org>.
Github user lizhanhui commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq-externals/pull/11#discussion_r111866538
  
    --- Diff: rocketmq-client4cpp/example/demo/AsyncProducer.cpp ---
    @@ -0,0 +1,253 @@
    +/**
    +* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
    +*
    +* Licensed under the Apache License, Version 2.0 (the "License");
    +* you may not use this file except in compliance with the License.
    +* You may obtain a copy of the License at
    +*
    +*     http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing, software
    +* distributed under the License is distributed on an "AS IS" BASIS,
    +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +* See the License for the specific language governing permissions and
    +* limitations under the License.
    +*/
    +
    +#include "Common.h"
    +#include "SendCallback.h"
    +#include "DefaultMQProducer.h"
    +using namespace rmq;
    +
    +long long g_lastUpdateTime = 0;
    +volatile long long g_cnt_total = 0;
    +volatile long long g_cnt_last = 0;
    +volatile long long g_cnt_succ = 0;
    +volatile long long g_cnt_fail = 0;
    +
    +
    +void Usage(const char* program)
    +{
    +    printf("Usage:%s ip:port [-g group] [-t topic] [-n count] [-s size] [-w logpath]\n", program);
    +    printf("\t -g group\n");
    +    printf("\t -t topic\n");
    +    printf("\t -n message count\n");
    +    printf("\t -s message size \n");
    +    printf("\t -w log path\n");
    +}
    +
    +
    +class SampleSendCallback : public SendCallback {
    +public:
    +    SampleSendCallback()
    +    {
    +    }
    +
    +    virtual ~SampleSendCallback()
    +    {
    +    }
    +
    +    int count()
    +    {
    +
    +        long long now = MyUtil::getNowMs();
    +        long long old = g_lastUpdateTime;
    +        long long total = g_cnt_succ + g_cnt_fail;
    +        if ((now - old) >= 1000)
    +        {
    +            if (__sync_bool_compare_and_swap(&g_lastUpdateTime, old, now))
    +            {
    +                long long time = now - old;
    +                int tps = (int)((total - g_cnt_last) * 1.0 / time * 1000.0);
    +                g_cnt_last = total;
    +
    +                MYDEBUG("[producer]succ: %lld, fail: %lld, TPS: %d\n",
    +                    g_cnt_succ, g_cnt_fail, tps);
    +            }
    +        }
    +    }
    +
    +    void onSuccess(SendResult& sendResult)
    +    {
    +        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
    +        __sync_fetch_and_add(&g_cnt_succ, 1);
    +        MYLOG("[%d]|succ|%s\n",  cnt, sendResult.toString().c_str());
    +    }
    +
    +    void onException(MQException& e)
    +    {
    +        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
    +        __sync_fetch_and_add(&g_cnt_fail, 1);
    +
    +        MYLOG("[%d]|fail|%s\n",  cnt, e.what());
    +    }
    +};
    +
    +int main(int argc, char *argv[]) {
    +    if (argc < 2)
    +    {
    +        Usage(argv[0]);
    +        return 0;
    +    }
    +
    +    std::string namesrv = argv[1];
    +    std::string group = "pg_test_group";
    +    std::string topic = "topic_test";
    +    int size = 32;
    +    int count = 1000;
    +
    +    for (int i=2; i< argc; i++)
    +    {
    +        if (strcmp(argv[i],"-g")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                group = argv[i+1];
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-t")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                topic = argv[i+1];
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-n")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                count = atoi(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-s")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                size = atoi(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-w")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                MyUtil::initLog(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else
    +        {
    +            Usage(argv[0]);
    +            return 0;
    +        }
    +    }
    +
    --- End diff --
    
    Best to translate these Chinese documentation to English so that we may have more developers from various backgrounds join easier. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals issue #11: [ROCKETMQ-129] Initialized the rocke...

Posted by hooligan520 <gi...@git.apache.org>.
Github user hooligan520 commented on the issue:

    https://github.com/apache/incubator-rocketmq-externals/pull/11
  
    @zhouxinyu my github email is hooligan_520@qq.com


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals issue #11: [ROCKETMQ-129] Initialized the rocke...

Posted by hooligan520 <gi...@git.apache.org>.
Github user hooligan520 commented on the issue:

    https://github.com/apache/incubator-rocketmq-externals/pull/11
  
    @lizhanhui remove all chinese


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals pull request #11: [ROCKETMQ-129] Initialized th...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-rocketmq-externals/pull/11


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals issue #11: [ROCKETMQ-129] Initialized the rocke...

Posted by zhouxinyu <gi...@git.apache.org>.
Github user zhouxinyu commented on the issue:

    https://github.com/apache/incubator-rocketmq-externals/pull/11
  
    @hooligan520 Pls provide your github email, so we can merge this PR with your account.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rocketmq-externals pull request #11: [ROCKETMQ-129] Initialized th...

Posted by hooligan520 <gi...@git.apache.org>.
Github user hooligan520 commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq-externals/pull/11#discussion_r111873729
  
    --- Diff: rocketmq-client4cpp/example/demo/AsyncProducer.cpp ---
    @@ -0,0 +1,253 @@
    +/**
    +* Copyright (C) 2013 suwenkuang ,hooligan_520@qq.com
    +*
    +* Licensed under the Apache License, Version 2.0 (the "License");
    +* you may not use this file except in compliance with the License.
    +* You may obtain a copy of the License at
    +*
    +*     http://www.apache.org/licenses/LICENSE-2.0
    +*
    +* Unless required by applicable law or agreed to in writing, software
    +* distributed under the License is distributed on an "AS IS" BASIS,
    +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +* See the License for the specific language governing permissions and
    +* limitations under the License.
    +*/
    +
    +#include "Common.h"
    +#include "SendCallback.h"
    +#include "DefaultMQProducer.h"
    +using namespace rmq;
    +
    +long long g_lastUpdateTime = 0;
    +volatile long long g_cnt_total = 0;
    +volatile long long g_cnt_last = 0;
    +volatile long long g_cnt_succ = 0;
    +volatile long long g_cnt_fail = 0;
    +
    +
    +void Usage(const char* program)
    +{
    +    printf("Usage:%s ip:port [-g group] [-t topic] [-n count] [-s size] [-w logpath]\n", program);
    +    printf("\t -g group\n");
    +    printf("\t -t topic\n");
    +    printf("\t -n message count\n");
    +    printf("\t -s message size \n");
    +    printf("\t -w log path\n");
    +}
    +
    +
    +class SampleSendCallback : public SendCallback {
    +public:
    +    SampleSendCallback()
    +    {
    +    }
    +
    +    virtual ~SampleSendCallback()
    +    {
    +    }
    +
    +    int count()
    +    {
    +
    +        long long now = MyUtil::getNowMs();
    +        long long old = g_lastUpdateTime;
    +        long long total = g_cnt_succ + g_cnt_fail;
    +        if ((now - old) >= 1000)
    +        {
    +            if (__sync_bool_compare_and_swap(&g_lastUpdateTime, old, now))
    +            {
    +                long long time = now - old;
    +                int tps = (int)((total - g_cnt_last) * 1.0 / time * 1000.0);
    +                g_cnt_last = total;
    +
    +                MYDEBUG("[producer]succ: %lld, fail: %lld, TPS: %d\n",
    +                    g_cnt_succ, g_cnt_fail, tps);
    +            }
    +        }
    +    }
    +
    +    void onSuccess(SendResult& sendResult)
    +    {
    +        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
    +        __sync_fetch_and_add(&g_cnt_succ, 1);
    +        MYLOG("[%d]|succ|%s\n",  cnt, sendResult.toString().c_str());
    +    }
    +
    +    void onException(MQException& e)
    +    {
    +        int cnt = __sync_fetch_and_add(&g_cnt_total, 1);
    +        __sync_fetch_and_add(&g_cnt_fail, 1);
    +
    +        MYLOG("[%d]|fail|%s\n",  cnt, e.what());
    +    }
    +};
    +
    +int main(int argc, char *argv[]) {
    +    if (argc < 2)
    +    {
    +        Usage(argv[0]);
    +        return 0;
    +    }
    +
    +    std::string namesrv = argv[1];
    +    std::string group = "pg_test_group";
    +    std::string topic = "topic_test";
    +    int size = 32;
    +    int count = 1000;
    +
    +    for (int i=2; i< argc; i++)
    +    {
    +        if (strcmp(argv[i],"-g")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                group = argv[i+1];
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-t")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                topic = argv[i+1];
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-n")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                count = atoi(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-s")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                size = atoi(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else if (strcmp(argv[i],"-w")==0)
    +        {
    +            if (i+1 < argc)
    +            {
    +                MyUtil::initLog(argv[i+1]);
    +                i++;
    +            }
    +            else
    +            {
    +                Usage(argv[0]);
    +                return 0;
    +            }
    +        }
    +        else
    +        {
    +            Usage(argv[0]);
    +            return 0;
    +        }
    +    }
    +
    --- End diff --
    
    ok\uff0cgood idea, i will create the roadmap and create some tickets for track this project


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---