[ 
https://issues.apache.org/jira/browse/ROCKETMQ-129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15972145#comment-15972145
 ] 

ASF GitHub Bot commented on ROCKETMQ-129:
-----------------------------------------

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 ,[email protected]
    +*
    +* 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,good idea, i will create the roadmap and create some tickets for track 
this project


> Provide C/C++ sdk
> -----------------
>
>                 Key: ROCKETMQ-129
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-129
>             Project: Apache RocketMQ
>          Issue Type: Wish
>          Components: rocketmq-client
>            Reporter: Eason Chen
>            Assignee: Xiaorui Wang
>
> A lot of C legacy system needs to integrate with RocketMQ but no C SDK, it is 
> hard to use for business since rebuild using java is a big effort.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to