rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ifplu...@apache.org
Subject [rocketmq-client-cpp] 07/29: refactor(consumer): remove const in consumeMessage
Date Tue, 29 Dec 2020 03:36:24 GMT
This is an automated email from the ASF dual-hosted git repository.

ifplusor pushed a commit to branch re_dev
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git

commit 28a47275e072fe0f317c65badccaf8897e809d24
Author: James Yin <ywhjames@hotmail.com>
AuthorDate: Fri Jul 24 11:04:07 2020 +0800

    refactor(consumer): remove const in consumeMessage
---
 example/AsyncProducer.cpp       | 1 +
 example/BatchProducer.cpp       | 1 +
 example/OrderlyProducer.cpp     | 1 +
 example/OrderlyPushConsumer.cpp | 3 ++-
 example/PushConsumer.cpp        | 3 ++-
 example/RequestReply.cpp        | 5 +++--
 example/SendDelayMsg.cpp        | 1 +
 example/SyncProducer.cpp        | 1 +
 example/TransactionProducer.cpp | 1 +
 example/common.h                | 7 ++-----
 include/MQMessageListener.h     | 2 +-
 src/extern/CPushConsumer.cpp    | 4 ++--
 12 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/example/AsyncProducer.cpp b/example/AsyncProducer.cpp
index 87e7368..130bc67 100644
--- a/example/AsyncProducer.cpp
+++ b/example/AsyncProducer.cpp
@@ -16,6 +16,7 @@
  */
 #include "common.h"
 #include "concurrent/latch.hpp"
+#include "DefaultMQProducer.h"
 
 using namespace rocketmq;
 
diff --git a/example/BatchProducer.cpp b/example/BatchProducer.cpp
index e698b66..7ed4cb7 100644
--- a/example/BatchProducer.cpp
+++ b/example/BatchProducer.cpp
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 #include "common.h"
+#include "DefaultMQProducer.h"
 
 using namespace rocketmq;
 
diff --git a/example/OrderlyProducer.cpp b/example/OrderlyProducer.cpp
index f2ce9f6..b0b602b 100644
--- a/example/OrderlyProducer.cpp
+++ b/example/OrderlyProducer.cpp
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 #include "common.h"
+#include "DefaultMQProducer.h"
 
 using namespace rocketmq;
 
diff --git a/example/OrderlyPushConsumer.cpp b/example/OrderlyPushConsumer.cpp
index 62959f1..edb3563 100644
--- a/example/OrderlyPushConsumer.cpp
+++ b/example/OrderlyPushConsumer.cpp
@@ -16,6 +16,7 @@
  */
 #include "common.h"
 #include "concurrent/latch.hpp"
+#include "DefaultMQPushConsumer.h"
 
 using namespace rocketmq;
 
@@ -27,7 +28,7 @@ class MyMsgListener : public MessageListenerOrderly {
   MyMsgListener() {}
   virtual ~MyMsgListener() {}
 
-  virtual ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) override
{
+  virtual ConsumeStatus consumeMessage(std::vector<MQMessageExt>& msgs) override
{
     auto old = g_msgCount.fetch_sub(msgs.size());
     if (old > 0) {
       for (size_t i = 0; i < msgs.size(); ++i) {
diff --git a/example/PushConsumer.cpp b/example/PushConsumer.cpp
index 0e7ccc9..aa3b9cb 100644
--- a/example/PushConsumer.cpp
+++ b/example/PushConsumer.cpp
@@ -16,6 +16,7 @@
  */
 #include "common.h"
 #include "concurrent/latch.hpp"
+#include "DefaultMQPushConsumer.h"
 #include "UtilAll.h"
 
 using namespace rocketmq;
@@ -27,7 +28,7 @@ class MyMsgListener : public MessageListenerConcurrently {
  public:
   virtual ~MyMsgListener() = default;
 
-  ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) override
{
+  ConsumeStatus consumeMessage(std::vector<MQMessageExt>& msgs) override {
     auto old = g_msgCount.fetch_sub(msgs.size());
     if (old > 0) {
       for (size_t i = 0; i < msgs.size(); ++i) {
diff --git a/example/RequestReply.cpp b/example/RequestReply.cpp
index ebb52e3..8fb7a3c 100644
--- a/example/RequestReply.cpp
+++ b/example/RequestReply.cpp
@@ -19,7 +19,8 @@
 #include "../src/common/UtilAll.h"
 #include "common.h"
 #include "MessageUtil.h"
-#include "common.h"
+#include "DefaultMQProducer.h"
+#include "DefaultMQPushConsumer.h"
 
 using namespace rocketmq;
 
@@ -28,7 +29,7 @@ class MyResponseMessageListener : public MessageListenerConcurrently {
   MyResponseMessageListener(DefaultMQProducer* replyProducer) : m_replyProducer(replyProducer)
{}
   virtual ~MyResponseMessageListener() = default;
 
-  ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) override
{
+  ConsumeStatus consumeMessage(std::vector<MQMessageExt>& msgs) override {
     for (const auto& msg : msgs) {
       try {
         std::cout << "handle message: " << msg.toString() << std::endl;
diff --git a/example/SendDelayMsg.cpp b/example/SendDelayMsg.cpp
index a1ed150..dd0ba72 100644
--- a/example/SendDelayMsg.cpp
+++ b/example/SendDelayMsg.cpp
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 #include "common.h"
+#include "DefaultMQProducer.h"
 
 using namespace rocketmq;
 
diff --git a/example/SyncProducer.cpp b/example/SyncProducer.cpp
index c5bbaf1..69b71a8 100644
--- a/example/SyncProducer.cpp
+++ b/example/SyncProducer.cpp
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 #include "common.h"
+#include "DefaultMQProducer.h"
 
 using namespace rocketmq;
 
diff --git a/example/TransactionProducer.cpp b/example/TransactionProducer.cpp
index 214d321..bddb559 100644
--- a/example/TransactionProducer.cpp
+++ b/example/TransactionProducer.cpp
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 #include "common.h"
+#include "TransactionMQProducer.h"
 
 using namespace rocketmq;
 
diff --git a/example/common.h b/example/common.h
index 3de4199..3a6e46e 100644
--- a/example/common.h
+++ b/example/common.h
@@ -30,12 +30,9 @@
 #include "ArgHelper.h"
 #endif
 
-#include "DefaultMQProducer.h"
-#include "DefaultMQPullConsumer.h"
-#include "DefaultMQPushConsumer.h"
-#include "TransactionMQProducer.h"
+#include "PullResult.h"
 
-std::atomic<int> g_msgCount(1);
+static std::atomic<int> g_msgCount(1);
 
 class RocketmqSendAndConsumerArgs {
  public:
diff --git a/include/MQMessageListener.h b/include/MQMessageListener.h
index b127632..11287f9 100644
--- a/include/MQMessageListener.h
+++ b/include/MQMessageListener.h
@@ -38,7 +38,7 @@ class ROCKETMQCLIENT_API MQMessageListener {
 
   virtual MessageListenerType getMessageListenerType() { return messageListenerDefaultly;
}
 
-  virtual ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) {
return RECONSUME_LATER; };
+  virtual ConsumeStatus consumeMessage(std::vector<MQMessageExt>& msgs) { return
RECONSUME_LATER; };
 };
 
 class ROCKETMQCLIENT_API MessageListenerConcurrently : virtual public MQMessageListener {
diff --git a/src/extern/CPushConsumer.cpp b/src/extern/CPushConsumer.cpp
index b93a94f..c875527 100644
--- a/src/extern/CPushConsumer.cpp
+++ b/src/extern/CPushConsumer.cpp
@@ -32,7 +32,7 @@ class MessageListenerInner : public MessageListenerConcurrently {
 
   ~MessageListenerInner() = default;
 
-  ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) override
{
+  ConsumeStatus consumeMessage(std::vector<MQMessageExt>& msgs) override {
     // to do user call back
     if (m_msgReceivedCallback == nullptr) {
       return RECONSUME_LATER;
@@ -56,7 +56,7 @@ class MessageListenerOrderlyInner : public MessageListenerOrderly {
   MessageListenerOrderlyInner(CPushConsumer* consumer, MessageCallBack callback)
       : m_consumer(consumer), m_msgReceivedCallback(callback) {}
 
-  ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) override
{
+  ConsumeStatus consumeMessage(std::vector<MQMessageExt>& msgs) override {
     if (m_msgReceivedCallback == nullptr) {
       return RECONSUME_LATER;
     }


Mime
View raw message