[Issue#94] Support send batch message to broker#95
[Issue#94] Support send batch message to broker#95ShannonDing merged 5 commits intoapache:masterfrom jonnxu:master
Conversation
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #include <stdio.h> |
There was a problem hiding this comment.
A new line after copyright?
| #include <mutex> | ||
| #include <thread> | ||
| #include <vector> | ||
| #include "common.h" |
There was a problem hiding this comment.
A new line before line28?
There was a problem hiding this comment.
i don't think need a new line between header files
| #include "common.h" | ||
|
|
||
| using namespace rocketmq; | ||
| using namespace std; |
There was a problem hiding this comment.
better to remove this using namespace std; statement.
There was a problem hiding this comment.
it doesn't matter for cpp file
|
|
||
| using namespace rocketmq; | ||
| using namespace std; | ||
| boost::atomic<bool> g_quit; |
There was a problem hiding this comment.
Let's use std::atomic instead of boost::atomic.
Or do you have any other consideration?
There was a problem hiding this comment.
copy from another sample
| msgs.push_back(msg2); | ||
| msgs.push_back(msg3); | ||
| try { | ||
| auto start = std::chrono::system_clock::now(); |
There was a problem hiding this comment.
| auto start = std::chrono::system_clock::now(); | |
| auto start = UtilAll::currentTimeMillis(); |
| auto duration = | ||
| std::chrono::duration_cast<std::chrono::milliseconds>(end - start); | ||
| if (duration.count() >= 500) { | ||
| std::cout << "send RT more than: " << duration.count() |
There was a problem hiding this comment.
use log instead of std::cout
There was a problem hiding this comment.
i suggest use std::cout or printf for samples because it can see the output in screen at once
| static std::string encode(MQMessage &message); | ||
| }; | ||
| } | ||
| #endif No newline at end of file |
There was a problem hiding this comment.
a new line at the end of this line.
|
Any plan on adding send batch message APIs to C APIs? |
Support send batch message
Support send batch message
What is the purpose of the change
#94 Support send batch message to broker
Brief changelog
Add two new APIs:
SendResult send(std::vector& msgs);
SendResult send(std::vector& msgs, const MQMessageQueue& mq);
Verifying this change
Producer send one batch message:
./bin/BatchProducer -t batch -m 1 -c test2222 -T 1 -n 127.0.0.1:9876 -g g1 nameserver: 101.132.96.164:9876
topic: batch
groupname: g1
produce content: test2222msgbody for test
msg count: 1
thread count: 1
tps_thread_ is null
send RT more than: 2807 ms with msgid:
per msg time: 2807ms
========================finished==============================
consumer receive three message:
./bin/PushConsumer -t batch -n 127.0.0.1:9876 -g g0 -m 10000 -T 1
nameserver: 127.0.0.1:9876
topic: batch
groupname: g0
produce content: msgbody for test
msg count: 10000
thread count: 1
tps_thread_ is null
msg: MessageExt [queueId=0, storeSize=196, queueOffset=48, sysFlag=0, bornTimestamp=1549729233501, bornHost=127.0.0.1, storeTimestamp=1549729234903, storeHost=127.0.0.1, msgId=730010AC000083060000E06492330100, commitLogOffset=365601006, bodyCRC=1949078420, reconsumeTimes=0, preparedTransactionOffset=0, Message [topic=batch, flag=0, tag=]]
body: test2222msgbody for test
TAGS : *
UNIQ_KEY : 730010AC000083060000E06492330100
WAIT : true
property1 : value1
msg: MessageExt [queueId=0, storeSize=213, queueOffset=49, sysFlag=0, bornTimestamp=1549729233501, bornHost=127.0.0.1, storeTimestamp=1549729234903, storeHost=127.0.0.1, msgId=730010AC000083060000E06492330200, commitLogOffset=365601202, bodyCRC=1949078420, reconsumeTimes=0, preparedTransactionOffset=0, Message [topic=batch, flag=0, tag=]]
body: test2222msgbody for test
TAGS : *
UNIQ_KEY : 730010AC000083060000E06492330200
WAIT : true
property1 : value1
property2 : value2
msg: MessageExt [queueId=0, storeSize=230, queueOffset=50, sysFlag=0, bornTimestamp=1549729233501, bornHost=127.0.0.1, storeTimestamp=1549729234903, storeHost=127.0.0.1, msgId=730010AC000083060000E06492330300, commitLogOffset=365601415, bodyCRC=1949078420, reconsumeTimes=0, preparedTransactionOffset=0, Message [topic=batch, flag=0, tag=*]]
body: test2222msgbody for test
TAGS : *
UNIQ_KEY : 730010AC000083060000E06492330300
WAIT : true
property1 : value1
property2 : value2
property3 : value3
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.