You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2020/02/07 01:33:40 UTC

[rocketmq-client-cpp] branch master updated: feat(interface): remove boost in header file and examples (#235)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 7151454  feat(interface): remove boost in header file and examples (#235)
7151454 is described below

commit 7151454ace1e5cb3a762d5e52bcd2791a8d087c3
Author: dinglei <li...@163.com>
AuthorDate: Fri Feb 7 09:33:34 2020 +0800

    feat(interface): remove boost in header file and examples (#235)
    
    feat(interface): remove boost in header file and examples
---
 example/AsyncProducer.cpp                          |    2 +-
 example/AsyncPushConsumer.cpp                      |   33 +-
 example/BatchProducer.cpp                          |   34 +-
 example/CAsyncProducer.c                           |   34 +-
 example/COrderlyAsyncProducer.c                    |   34 +-
 example/OrderProducer.cpp                          |   35 +-
 example/OrderlyPushConsumer.cpp                    |   34 +-
 example/PullConsumeMessage.c                       |   36 +-
 example/PullConsumer.cpp                           |   31 +-
 example/PushConsumeMessage.c                       |   34 +-
 example/PushConsumer.cpp                           |   30 +-
 example/PushConsumerOrderly.c                      |   32 +-
 example/README.md                                  |    5 +-
 example/SendDelayMsg.cpp                           |   32 +-
 example/SyncProducer.cpp                           |   34 +-
 example/common.h                                   |   66 +-
 include/DefaultMQProducer.h                        |  106 +-
 include/DefaultMQPullConsumer.h                    |   70 +-
 include/DefaultMQPushConsumer.h                    |  152 ++-
 include/MQClient.h                                 |  240 +----
 include/TransactionMQProducer.h                    |   99 +-
 src/common/Arg_helper.cpp                          |    2 +-
 src/common/AsyncArg.h                              |   72 +-
 src/common/AsyncCallbackWrap.h                     |    2 +-
 src/common/ByteOrder.h                             |   32 +-
 src/common/ClientRPCHook.cpp                       |    2 +-
 src/common/ClientRPCHook.h                         |    2 +-
 src/common/CommunicationMode.h                     |    2 +-
 src/common/{MQClient.cpp => DefaultMQClient.cpp}   |   82 +-
 src/common/FilterAPI.h                             |    2 +-
 src/common/InputStream.cpp                         |   32 +-
 src/common/InputStream.h                           |   32 +-
 src/common/MemoryInputStream.cpp                   |   32 +-
 src/common/MemoryInputStream.h                     |   32 +-
 src/common/MemoryOutputStream.cpp                  |   32 +-
 src/common/MemoryOutputStream.h                    |   32 +-
 src/common/MessageSysFlag.cpp                      |    2 +-
 src/common/MessageSysFlag.h                        |    2 +-
 src/common/OutputStream.cpp                        |   32 +-
 src/common/OutputStream.h                          |   32 +-
 src/common/PermName.cpp                            |    2 +-
 src/common/PermName.h                              |    2 +-
 src/common/PullSysFlag.cpp                         |    2 +-
 src/common/PullSysFlag.h                           |    2 +-
 src/common/ServiceState.h                          |    2 +-
 src/common/SubscriptionGroupConfig.h               |    2 +-
 src/common/TopAddressing.cpp                       |    2 +-
 src/common/TopicConfig.cpp                         |    2 +-
 src/common/TopicConfig.h                           |    2 +-
 src/common/TopicFilterType.h                       |    2 +-
 src/common/UtilAll.cpp                             |    2 +-
 src/common/UtilAll.h                               |    2 +-
 src/common/Validators.cpp                          |    2 +-
 src/common/Validators.h                            |    2 +-
 src/common/VirtualEnvUtil.h                        |    2 +-
 src/common/big_endian.cpp                          |    2 +-
 src/common/big_endian.h                            |    2 +-
 src/common/dataBlock.cpp                           |   32 +-
 src/common/dataBlock.h                             |   32 +-
 src/common/sync_http_client.cpp                    |    6 +-
 src/common/sync_http_client.h                      |    2 +-
 src/common/url.cpp                                 |    2 +-
 src/common/url.h                                   |    2 +-
 src/consumer/ConsumeMsgService.h                   |    5 +-
 src/consumer/DefaultMQPullConsumer.cpp             |  449 ++-------
 ...lConsumer.cpp => DefaultMQPullConsumerImpl.cpp} |  116 +--
 .../consumer/DefaultMQPullConsumerImpl.h           |  296 +++---
 src/consumer/DefaultMQPushConsumer.cpp             | 1052 ++------------------
 ...hConsumer.cpp => DefaultMQPushConsumerImpl.cpp} |  134 +--
 .../consumer/DefaultMQPushConsumerImpl.h           |  330 +++---
 src/consumer/Rebalance.cpp                         |   10 +-
 src/extern/CMessageExt.cpp                         |    2 +-
 src/extern/CProducer.cpp                           |    1 +
 {include => src/include}/BatchMessage.h            |    0
 .../MQClient.h => src/include/DefaultMQClient.h    |  395 ++++----
 {include => src/include}/MQConsumer.h              |  136 +--
 {include => src/include}/MQProducer.h              |  122 +--
 {include => src/include}/QueryResult.h             |   84 +-
 {include => src/include}/SendMessageHook.h         |   96 +-
 src/log/Logging.h                                  |    2 +-
 src/message/BatchMessage.cpp                       |    2 +-
 src/producer/DefaultMQProducer.cpp                 |  728 +++-----------
 ...ultMQProducer.cpp => DefaultMQProducerImpl.cpp} |  121 +--
 .../producer/DefaultMQProducerImpl.h               |  236 ++---
 src/producer/TransactionMQProducer.cpp             |  337 +++----
 ...QProducer.cpp => TransactionMQProducerImpl.cpp} |   48 +-
 .../producer/TransactionMQProducerImpl.h           |   14 +-
 87 files changed, 2361 insertions(+), 4096 deletions(-)

diff --git a/example/AsyncProducer.cpp b/example/AsyncProducer.cpp
index 279cea3..5be900c 100644
--- a/example/AsyncProducer.cpp
+++ b/example/AsyncProducer.cpp
@@ -29,7 +29,7 @@
 
 using namespace rocketmq;
 
-boost::atomic<bool> g_quit;
+std::atomic<bool> g_quit;
 std::mutex g_mtx;
 std::condition_variable g_finished;
 SendCallback* g_callback = NULL;
diff --git a/example/AsyncPushConsumer.cpp b/example/AsyncPushConsumer.cpp
index 414f967..671c2e4 100644
--- a/example/AsyncPushConsumer.cpp
+++ b/example/AsyncPushConsumer.cpp
@@ -1,28 +1,25 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdlib.h>
 #include <string.h>
 
 #include <condition_variable>
 #include <iomanip>
 #include <iostream>
-#include <map>
-#include <mutex>
-#include <string>
 #include <vector>
 
 #include "common.h"
diff --git a/example/BatchProducer.cpp b/example/BatchProducer.cpp
index d889ea9..18f33cb 100644
--- a/example/BatchProducer.cpp
+++ b/example/BatchProducer.cpp
@@ -1,26 +1,24 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <condition_variable>
 #include <iomanip>
-#include <iomanip>
-#include <iostream>
 #include <iostream>
 #include <mutex>
 #include <thread>
@@ -29,7 +27,7 @@
 
 using namespace rocketmq;
 using namespace std;
-boost::atomic<bool> g_quit;
+std::atomic<bool> g_quit;
 std::mutex g_mtx;
 std::condition_variable g_finished;
 TpsReportService g_tps;
diff --git a/example/CAsyncProducer.c b/example/CAsyncProducer.c
index 2d2af61..9837c1f 100644
--- a/example/CAsyncProducer.c
+++ b/example/CAsyncProducer.c
@@ -1,30 +1,30 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdio.h>
-#include "CProducer.h"
 #include "CCommon.h"
 #include "CMessage.h"
+#include "CProducer.h"
 #include "CSendResult.h"
 #ifdef _WIN32
 #include <windows.h>
 #else
-#include <unistd.h>
 #include <memory.h>
+#include <unistd.h>
 #endif
 
 void thread_sleep(unsigned milliseconds) {
diff --git a/example/COrderlyAsyncProducer.c b/example/COrderlyAsyncProducer.c
index 48a822c..b48fb54 100644
--- a/example/COrderlyAsyncProducer.c
+++ b/example/COrderlyAsyncProducer.c
@@ -1,30 +1,30 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdio.h>
-#include "CProducer.h"
 #include "CCommon.h"
 #include "CMessage.h"
+#include "CProducer.h"
 #include "CSendResult.h"
 #ifdef _WIN32
 #include <windows.h>
 #else
-#include <unistd.h>
 #include <memory.h>
+#include <unistd.h>
 #endif
 
 void thread_sleep(unsigned milliseconds) {
diff --git a/example/OrderProducer.cpp b/example/OrderProducer.cpp
index 613add4..402e916 100644
--- a/example/OrderProducer.cpp
+++ b/example/OrderProducer.cpp
@@ -1,27 +1,26 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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 <stdio.h>
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdlib.h>
 #include <string.h>
 
 #include <condition_variable>
 #include <iomanip>
 #include <iostream>
-#include <mutex>
 #include <thread>
 
 #include "common.h"
@@ -30,7 +29,7 @@ using namespace rocketmq;
 
 std::condition_variable g_finished;
 std::mutex g_mtx;
-boost::atomic<bool> g_quit(false);
+std::atomic<bool> g_quit(false);
 
 class SelectMessageQueueByHash : public MessageQueueSelector {
  public:
diff --git a/example/OrderlyPushConsumer.cpp b/example/OrderlyPushConsumer.cpp
index c8a9eaa..174e2b3 100644
--- a/example/OrderlyPushConsumer.cpp
+++ b/example/OrderlyPushConsumer.cpp
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdlib.h>
 #include <string.h>
 
@@ -31,8 +31,8 @@ using namespace rocketmq;
 
 std::condition_variable g_finished;
 std::mutex g_mtx;
-boost::atomic<int> g_consumedCount(0);
-boost::atomic<bool> g_quit(false);
+std::atomic<int> g_consumedCount(0);
+std::atomic<bool> g_quit(false);
 TpsReportService g_tps;
 
 class MyMsgListener : public MessageListenerOrderly {
diff --git a/example/PullConsumeMessage.c b/example/PullConsumeMessage.c
index 0868d08..f9b9bc2 100644
--- a/example/PullConsumeMessage.c
+++ b/example/PullConsumeMessage.c
@@ -1,31 +1,31 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdio.h>
-#include "CPullConsumer.h"
 #include "CCommon.h"
 #include "CMessageExt.h"
-#include "CPullResult.h"
 #include "CMessageQueue.h"
+#include "CPullConsumer.h"
+#include "CPullResult.h"
 #ifdef _WIN32
 #include <windows.h>
 #else
-#include <unistd.h>
 #include <memory.h>
+#include <unistd.h>
 #endif
 
 void thread_sleep(unsigned milliseconds) {
diff --git a/example/PullConsumer.cpp b/example/PullConsumer.cpp
index 52e9094..e85a821 100644
--- a/example/PullConsumer.cpp
+++ b/example/PullConsumer.cpp
@@ -1,22 +1,21 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdlib.h>
-#include <string.h>
 
 #include <chrono>
 #include <iomanip>
diff --git a/example/PushConsumeMessage.c b/example/PushConsumeMessage.c
index 2cb9c3f..85ea28c 100644
--- a/example/PushConsumeMessage.c
+++ b/example/PushConsumeMessage.c
@@ -1,29 +1,29 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdio.h>
-#include "CPushConsumer.h"
 #include "CCommon.h"
 #include "CMessageExt.h"
+#include "CPushConsumer.h"
 #ifdef _WIN32
 #include <windows.h>
 #else
-#include <unistd.h>
 #include <memory.h>
+#include <unistd.h>
 #endif
 
 void thread_sleep(unsigned milliseconds) {
diff --git a/example/PushConsumer.cpp b/example/PushConsumer.cpp
index f0d4926..0b69ca5 100644
--- a/example/PushConsumer.cpp
+++ b/example/PushConsumer.cpp
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdlib.h>
 #include <string.h>
 
diff --git a/example/PushConsumerOrderly.c b/example/PushConsumerOrderly.c
index 4b2c2bb..9601799 100644
--- a/example/PushConsumerOrderly.c
+++ b/example/PushConsumerOrderly.c
@@ -1,26 +1,26 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 #ifndef WIN32
 #include <unistd.h>
 #endif
 #include <stdio.h>
-#include "CPushConsumer.h"
 #include "CCommon.h"
 #include "CMessageExt.h"
+#include "CPushConsumer.h"
 
 int doConsumeMessage(struct CPushConsumer* consumer, CMessageExt* msgExt) {
   printf("Hello,doConsumeMessage by Application!\n");
diff --git a/example/README.md b/example/README.md
index 91965d0..378a4ea 100644
--- a/example/README.md
+++ b/example/README.md
@@ -1,4 +1 @@
-1. AsyncProducer
-2. OrderlyProducer
-3. SyncProducer
-
+1. AsyncProducer 2. OrderlyProducer 3. SyncProducer
diff --git a/example/SendDelayMsg.cpp b/example/SendDelayMsg.cpp
index 2486427..860f5b3 100644
--- a/example/SendDelayMsg.cpp
+++ b/example/SendDelayMsg.cpp
@@ -1,27 +1,25 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <condition_variable>
 #include <iomanip>
-#include <iomanip>
-#include <iostream>
 #include <iostream>
 #include <mutex>
 #include <thread>
diff --git a/example/SyncProducer.cpp b/example/SyncProducer.cpp
index 0edb6dc..5d66da2 100644
--- a/example/SyncProducer.cpp
+++ b/example/SyncProducer.cpp
@@ -1,27 +1,25 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <condition_variable>
 #include <iomanip>
-#include <iomanip>
-#include <iostream>
 #include <iostream>
 #include <mutex>
 #include <thread>
@@ -30,7 +28,7 @@
 
 using namespace rocketmq;
 
-boost::atomic<bool> g_quit;
+std::atomic<bool> g_quit;
 std::mutex g_mtx;
 std::condition_variable g_finished;
 TpsReportService g_tps;
diff --git a/example/common.h b/example/common.h
index 5b674c3..e3f1b09 100644
--- a/example/common.h
+++ b/example/common.h
@@ -1,44 +1,45 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 #ifndef ROCKETMQ_CLIENT4CPP_EXAMPLE_COMMON_H_
 #define ROCKETMQ_CLIENT4CPP_EXAMPLE_COMMON_H_
 
-#include <boost/atomic.hpp>
-#include <boost/chrono.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/thread.hpp>
+#include <atomic>
+#include <chrono>
 #include <iostream>
+#include <memory>
 #include <string>
 #include <thread>
 #include <vector>
-
+#ifndef WIN32
+#include "unistd.h"
+#endif
 #include "Arg_helper.h"
 #include "DefaultMQProducer.h"
 #include "DefaultMQPullConsumer.h"
 #include "DefaultMQPushConsumer.h"
 using namespace std;
 
-boost::atomic<int> g_msgCount(1);
+std::atomic<int> g_msgCount(1);
 
 class RocketmqSendAndConsumerArgs {
  public:
   RocketmqSendAndConsumerArgs()
       : body("msgbody for test"),
-        thread_count(boost::thread::hardware_concurrency()),
+        thread_count(std::thread::hardware_concurrency()),
         broadcasting(false),
         syncpush(false),
         SelectUnactiveBroker(false),
@@ -69,7 +70,7 @@ class TpsReportService {
       std::cout << "tps_thread_ is null" << std::endl;
       return;
     }
-    tps_thread_.reset(new boost::thread(boost::bind(&TpsReportService::TpsReport, this)));
+    tps_thread_.reset(new std::thread(std::bind(&TpsReportService::TpsReport, this)));
   }
 
   ~TpsReportService() {
@@ -86,28 +87,19 @@ class TpsReportService {
 
   void TpsReport() {
     while (!quit_flag_.load()) {
-      boost::this_thread::sleep_for(tps_interval_);
+      std::this_thread::sleep_for(tps_interval_);
       std::cout << "tps: " << tps_count_.load() << std::endl;
       tps_count_.store(0);
     }
   }
 
  private:
-  boost::chrono::seconds tps_interval_;
-  boost::shared_ptr<boost::thread> tps_thread_;
-  boost::atomic<bool> quit_flag_;
-  boost::atomic<long> tps_count_;
+  std::chrono::seconds tps_interval_;
+  std::shared_ptr<std::thread> tps_thread_;
+  std::atomic<bool> quit_flag_;
+  std::atomic<long> tps_count_;
 };
 
-/*
-static void PrintResult(rocketmq::SendResult* result) {
-  std::cout << "sendresult = " << result->getSendStatus()
-            << ", msgid = " << result->getMsgId()
-            << ", queueOffset = " << result->getQueueOffset() << ","
-            << result->getMessageQueue().toString() << endl;
-}
-*/
-
 void PrintPullResult(rocketmq::PullResult* result) {
   std::cout << result->toString() << std::endl;
   if (result->pullStatus == rocketmq::FOUND) {
diff --git a/include/DefaultMQProducer.h b/include/DefaultMQProducer.h
index 630e765..a96a59b 100644
--- a/include/DefaultMQProducer.h
+++ b/include/DefaultMQProducer.h
@@ -18,25 +18,25 @@
 #ifndef __DEFAULTMQPRODUCER_H__
 #define __DEFAULTMQPRODUCER_H__
 
-#include "BatchMessage.h"
+#include "AsyncCallback.h"
+#include "MQClient.h"
 #include "MQMessageQueue.h"
-#include "MQProducer.h"
+#include "MQSelector.h"
 #include "RocketMQClient.h"
 #include "SendResult.h"
+#include "SessionCredentials.h"
 
 namespace rocketmq {
+class DefaultMQProducerImpl;
 //<!***************************************************************************
-class ROCKETMQCLIENT_API DefaultMQProducer : public MQProducer {
+class ROCKETMQCLIENT_API DefaultMQProducer {
  public:
   DefaultMQProducer(const std::string& groupname);
   virtual ~DefaultMQProducer();
 
-  //<!begin mqadmin;
   virtual void start();
   virtual void shutdown();
-  //<!end mqadmin;
 
-  //<! begin MQProducer;
   virtual SendResult send(MQMessage& msg, bool bSelectActiveBroker = false);
   virtual SendResult send(MQMessage& msg, const MQMessageQueue& mq);
   virtual SendResult send(MQMessage& msg, MessageQueueSelector* selector, void* arg);
@@ -53,16 +53,14 @@ class ROCKETMQCLIENT_API DefaultMQProducer : public MQProducer {
   virtual void sendOneway(MQMessage& msg, bool bSelectActiveBroker = false);
   virtual void sendOneway(MQMessage& msg, const MQMessageQueue& mq);
   virtual void sendOneway(MQMessage& msg, MessageQueueSelector* selector, void* arg);
-  //<! end MQProducer;
 
-  // set and get timeout of per msg
   int getSendMsgTimeout() const;
   void setSendMsgTimeout(int sendMsgTimeout);
 
   /*
-  *  if msgBody size is large than m_compressMsgBodyOverHowmuch
-      rocketmq cpp will compress msgBody according to compressLevel
-  */
+   *  if msgBody size is large than m_compressMsgBodyOverHowmuch
+   *  rocketmq cpp will compress msgBody according to compressLevel
+   */
   int getCompressMsgBodyOverHowmuch() const;
   void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch);
   int getCompressLevel() const;
@@ -78,40 +76,64 @@ class ROCKETMQCLIENT_API DefaultMQProducer : public MQProducer {
 
   int getRetryTimes4Async() const;
   void setRetryTimes4Async(int times);
+  const std::string& getNamesrvAddr() const;
+  void setNamesrvAddr(const std::string& namesrvAddr);
+  const std::string& getNamesrvDomain() const;
+  void setNamesrvDomain(const std::string& namesrvDomain);
+  const std::string& getInstanceName() const;
+  void setInstanceName(const std::string& instanceName);
+  // nameSpace
+  const std::string& getNameSpace() const;
+  void setNameSpace(const std::string& nameSpace);
+  const std::string& getGroupName() const;
+  void setGroupName(const std::string& groupname);
 
- protected:
-  SendResult sendAutoRetrySelectImpl(MQMessage& msg,
-                                     MessageQueueSelector* pSelector,
-                                     void* pArg,
-                                     int communicationMode,
-                                     SendCallback* pSendCallback,
-                                     int retryTimes,
-                                     bool bActiveBroker = false);
-  SendResult sendSelectImpl(MQMessage& msg,
-                            MessageQueueSelector* pSelector,
-                            void* pArg,
-                            int communicationMode,
-                            SendCallback* sendCallback);
-  SendResult sendDefaultImpl(MQMessage& msg,
-                             int communicationMode,
-                             SendCallback* pSendCallback,
-                             bool bActiveBroker = false);
-  SendResult sendKernelImpl(MQMessage& msg,
-                            const MQMessageQueue& mq,
-                            int communicationMode,
-                            SendCallback* pSendCallback);
-  bool tryToCompressMessage(MQMessage& msg);
-  BatchMessage buildBatchMessage(std::vector<MQMessage>& msgs);
-  bool dealWithNameSpace();
+  // log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
+  // log file num is 3, each log size is 100M
+  void setLogLevel(elogLevel inputLevel);
+  elogLevel getLogLevel();
+  void setLogFileSizeAndNum(int fileNum, long perFileSize);  // perFileSize is MB unit
+
+  /** set TcpTransport pull thread num, which dermine the num of threads to
+   *  distribute network data,
+   *  1. its default value is CPU num, it must be setted before producer/consumer
+   *     start, minimum value is CPU num;
+   *  2. this pullThread num must be tested on your environment to find the best
+   *     value for RT of sendMsg or delay time of consume msg before you change it;
+   *  3. producer and consumer need different pullThread num, if set this num,
+   *     producer and consumer must set different instanceName.
+   **/
+  void setTcpTransportPullThreadNum(int num);
+  const int getTcpTransportPullThreadNum() const;
+
+  /** timeout of tcp connect, it is same meaning for both producer and consumer;
+   *    1. default value is 3000ms
+   *    2. input parameter could only be milliSecond, suggestion value is
+   *       1000-3000ms;
+   **/
+  void setTcpTransportConnectTimeout(uint64_t timeout);  // ms
+  const uint64_t getTcpTransportConnectTimeout() const;
+
+  /** timeout of tryLock tcpTransport before sendMsg/pullMsg, if timeout,
+   *  returns NULL
+   *    1. paremeter unit is ms, default value is 3000ms, the minimun value is 1000ms
+   *       suggestion value is 3000ms;
+   *    2. if configured with value smaller than 1000ms, the tryLockTimeout value
+   *       will be setted to 1000ms
+   **/
+  void setTcpTransportTryLockTimeout(uint64_t timeout);  // ms
+  const uint64_t getTcpTransportTryLockTimeout() const;
+
+  void setUnitName(std::string unitName);
+  const std::string& getUnitName() const;
+
+  void setSessionCredentials(const std::string& accessKey,
+                             const std::string& secretKey,
+                             const std::string& accessChannel);
+  const SessionCredentials& getSessionCredentials() const;
 
  private:
-  int m_sendMsgTimeout;
-  int m_compressMsgBodyOverHowmuch;
-  int m_maxMessageSize;  //<! default:128K;
-  // bool m_retryAnotherBrokerWhenNotStoreOK;
-  int m_compressLevel;
-  int m_retryTimes;
-  int m_retryTimes4Async;
+  DefaultMQProducerImpl* impl;
 };
 //<!***************************************************************************
 }  // namespace rocketmq
diff --git a/include/DefaultMQPullConsumer.h b/include/DefaultMQPullConsumer.h
index 8e1612d..552bbab 100644
--- a/include/DefaultMQPullConsumer.h
+++ b/include/DefaultMQPullConsumer.h
@@ -20,19 +20,21 @@
 
 #include <set>
 #include <string>
-#include "MQConsumer.h"
+#include "AsyncCallback.h"
+#include "ConsumeType.h"
+#include "MQClient.h"
+#include "MQMessage.h"
+#include "MQMessageExt.h"
 #include "MQMessageQueue.h"
 #include "MQueueListener.h"
+#include "PullResult.h"
 #include "RocketMQClient.h"
 
 namespace rocketmq {
-class Rebalance;
 class SubscriptionData;
-class OffsetStore;
-class PullAPIWrapper;
-class ConsumerRunningInfo;
+class DefaultMQPullConsumerImpl;
 //<!***************************************************************************
-class ROCKETMQCLIENT_API DefaultMQPullConsumer : public MQConsumer {
+class ROCKETMQCLIENT_API DefaultMQPullConsumer {
  public:
   DefaultMQPullConsumer(const std::string& groupname);
   virtual ~DefaultMQPullConsumer();
@@ -41,11 +43,30 @@ class ROCKETMQCLIENT_API DefaultMQPullConsumer : public MQConsumer {
   virtual void start();
   virtual void shutdown();
   //<!end mqadmin;
-
+  const std::string& getNamesrvAddr() const;
+  void setNamesrvAddr(const std::string& namesrvAddr);
+  const std::string& getNamesrvDomain() const;
+  void setNamesrvDomain(const std::string& namesrvDomain);
+  const std::string& getInstanceName() const;
+  void setInstanceName(const std::string& instanceName);
+  // nameSpace
+  const std::string& getNameSpace() const;
+  void setNameSpace(const std::string& nameSpace);
+  const std::string& getGroupName() const;
+  void setGroupName(const std::string& groupname);
+
+  // log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
+  // log file num is 3, each log size is 100M
+  void setLogLevel(elogLevel inputLevel);
+  elogLevel getLogLevel();
+  void setLogFileSizeAndNum(int fileNum, long perFileSize);  // perFileSize is MB unit
+
+  void setSessionCredentials(const std::string& accessKey,
+                             const std::string& secretKey,
+                             const std::string& accessChannel);
+  const SessionCredentials& getSessionCredentials() const;
   //<!begin MQConsumer
-  virtual bool sendMessageBack(MQMessageExt& msg, int delayLevel, std::string& brokerName);
   virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs);
-  virtual void doRebalance();
   virtual void persistConsumerOffset();
   virtual void persistConsumerOffsetByResetOffset();
   virtual void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info);
@@ -54,8 +75,6 @@ class ROCKETMQCLIENT_API DefaultMQPullConsumer : public MQConsumer {
   virtual void getSubscriptions(std::vector<SubscriptionData>&);
   virtual void updateConsumeOffset(const MQMessageQueue& mq, int64 offset);
   virtual void removeConsumeOffset(const MQMessageQueue& mq);
-  virtual bool producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest);
-  virtual Rebalance* getRebalance() const;
   //<!end MQConsumer;
 
   void registerMessageQueueListener(const std::string& topic, MQueueListener* pListener);
@@ -105,8 +124,6 @@ class ROCKETMQCLIENT_API DefaultMQPullConsumer : public MQConsumer {
                            int maxNums,
                            PullCallback* pPullCallback);
 
-  virtual ConsumerRunningInfo* getConsumerRunningInfo() { return NULL; }
-
   int64 fetchConsumeOffset(const MQMessageQueue& mq, bool fromStore);
 
   void fetchMessageQueuesInBalance(const std::string& topic, std::vector<MQMessageQueue> mqs);
@@ -116,32 +133,7 @@ class ROCKETMQCLIENT_API DefaultMQPullConsumer : public MQConsumer {
   void persistConsumerOffset4PullConsumer(const MQMessageQueue& mq);
 
  private:
-  void checkConfig();
-  void copySubscription();
-  bool dealWithNameSpace();
-
-  PullResult pullSyncImpl(const MQMessageQueue& mq,
-                          const std::string& subExpression,
-                          int64 offset,
-                          int maxNums,
-                          bool block);
-
-  void pullAsyncImpl(const MQMessageQueue& mq,
-                     const std::string& subExpression,
-                     int64 offset,
-                     int maxNums,
-                     bool block,
-                     PullCallback* pPullCallback);
-
-  void subscriptionAutomatically(const std::string& topic);
-
- private:
-  std::set<std::string> m_registerTopics;
-
-  MQueueListener* m_pMessageQueueListener;
-  OffsetStore* m_pOffsetStore;
-  Rebalance* m_pRebalance;
-  PullAPIWrapper* m_pPullAPIWrapper;
+  DefaultMQPullConsumerImpl* impl;
 };
 //<!***************************************************************************
 }  // namespace rocketmq
diff --git a/include/DefaultMQPushConsumer.h b/include/DefaultMQPushConsumer.h
index 7f69258..cd4e599 100644
--- a/include/DefaultMQPushConsumer.h
+++ b/include/DefaultMQPushConsumer.h
@@ -18,87 +18,34 @@
 #ifndef __DEFAULTMQPUSHCONSUMER_H__
 #define __DEFAULTMQPUSHCONSUMER_H__
 
-#include <boost/asio.hpp>
-#include <boost/asio/io_service.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/scoped_ptr.hpp>
-#include <boost/thread/thread.hpp>
 #include <string>
 #include "AsyncCallback.h"
-#include "MQConsumer.h"
+#include "ConsumeType.h"
+#include "MQClient.h"
 #include "MQMessageListener.h"
 #include "MQMessageQueue.h"
 
 namespace rocketmq {
-
-class Rebalance;
-class SubscriptionData;
-class OffsetStore;
-class PullAPIWrapper;
-class PullRequest;
-class ConsumeMsgService;
-class TaskQueue;
-class TaskThread;
-class AsyncPullCallback;
-class ConsumerRunningInfo;
+class DefaultMQPushConsumerImpl;
 //<!***************************************************************************
-class ROCKETMQCLIENT_API DefaultMQPushConsumer : public MQConsumer {
+class ROCKETMQCLIENT_API DefaultMQPushConsumer {
  public:
   DefaultMQPushConsumer(const std::string& groupname);
-  void boost_asio_work();
+
   virtual ~DefaultMQPushConsumer();
 
   //<!begin mqadmin;
   virtual void start();
   virtual void shutdown();
-  //<!end mqadmin;
-
-  //<!begin MQConsumer
-  virtual bool sendMessageBack(MQMessageExt& msg, int delayLevel, std::string& brokerName);
-  virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs);
-  virtual void doRebalance();
-  virtual void persistConsumerOffset();
-  virtual void persistConsumerOffsetByResetOffset();
-  virtual void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info);
+
   virtual ConsumeType getConsumeType();
   virtual ConsumeFromWhere getConsumeFromWhere();
   void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere);
-  virtual void getSubscriptions(std::vector<SubscriptionData>&);
-  virtual void updateConsumeOffset(const MQMessageQueue& mq, int64 offset);
-  virtual void removeConsumeOffset(const MQMessageQueue& mq);
-  virtual PullResult pull(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums) {
-    return PullResult();
-  }
-  virtual void pull(const MQMessageQueue& mq,
-                    const std::string& subExpression,
-                    int64 offset,
-                    int maxNums,
-                    PullCallback* pPullCallback) {}
-  virtual ConsumerRunningInfo* getConsumerRunningInfo();
-  //<!end MQConsumer;
 
   void registerMessageListener(MQMessageListener* pMessageListener);
   MessageListenerType getMessageListenerType();
   void subscribe(const std::string& topic, const std::string& subExpression);
 
-  OffsetStore* getOffsetStore() const;
-  virtual Rebalance* getRebalance() const;
-  ConsumeMsgService* getConsumerMsgService() const;
-
-  virtual bool producePullMsgTask(boost::weak_ptr<PullRequest>);
-  virtual bool producePullMsgTaskLater(boost::weak_ptr<PullRequest>, int millis);
-  static void static_triggerNextPullRequest(void* context,
-                                            boost::asio::deadline_timer* t,
-                                            boost::weak_ptr<PullRequest>);
-  void triggerNextPullRequest(boost::asio::deadline_timer* t, boost::weak_ptr<PullRequest>);
-  void runPullMsgQueue(TaskQueue* pTaskQueue);
-  void pullMessage(boost::weak_ptr<PullRequest> pullrequest);
-  void pullMessageAsync(boost::weak_ptr<PullRequest> pullrequest);
-  void setAsyncPull(bool asyncFlag);
-  AsyncPullCallback* getAsyncPullCallBack(boost::weak_ptr<PullRequest>, MQMessageQueue msgQueue);
-  void shutdownAsyncPullCallBack();
-
   /*
     for orderly consume, set the pull num of message size by each pullMsg,
     default value is 1;
@@ -128,37 +75,66 @@ class ROCKETMQCLIENT_API DefaultMQPushConsumer : public MQConsumer {
   void setMaxCacheMsgSizePerQueue(int maxCacheSize);
   int getMaxCacheMsgSizePerQueue() const;
 
- private:
-  void checkConfig();
-  void copySubscription();
-  void updateTopicSubscribeInfoWhenSubscriptionChanged();
-  bool dealWithNameSpace();
-
- private:
-  uint64_t m_startTime;
-  ConsumeFromWhere m_consumeFromWhere;
-  std::map<std::string, std::string> m_subTopics;
-  int m_consumeThreadCount;
-  OffsetStore* m_pOffsetStore;
-  Rebalance* m_pRebalance;
-  PullAPIWrapper* m_pPullAPIWrapper;
-  ConsumeMsgService* m_consumerService;
-  MQMessageListener* m_pMessageListener;
-  int m_consumeMessageBatchMaxSize;
-  int m_maxMsgCacheSize;
-  int m_maxReconsumeTimes = -1;
-  boost::asio::io_service m_async_ioService;
-  boost::scoped_ptr<boost::thread> m_async_service_thread;
-
-  typedef std::map<MQMessageQueue, AsyncPullCallback*> PullMAP;
-  PullMAP m_PullCallback;
-  bool m_asyncPull;
-  int m_asyncPullTimeout;
-  int m_pullMsgThreadPoolNum;
+  MessageModel getMessageModel() const;
+  void setMessageModel(MessageModel messageModel);
+  const std::string& getNamesrvAddr() const;
+  void setNamesrvAddr(const std::string& namesrvAddr);
+  const std::string& getNamesrvDomain() const;
+  void setNamesrvDomain(const std::string& namesrvDomain);
+  const std::string& getInstanceName() const;
+  void setInstanceName(const std::string& instanceName);
+  // nameSpace
+  const std::string& getNameSpace() const;
+  void setNameSpace(const std::string& nameSpace);
+  const std::string& getGroupName() const;
+  void setGroupName(const std::string& groupname);
+
+  // log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
+  // log file num is 3, each log size is 100M
+  void setLogLevel(elogLevel inputLevel);
+  elogLevel getLogLevel();
+  void setLogFileSizeAndNum(int fileNum, long perFileSize);  // perFileSize is MB unit
+
+  /** set TcpTransport pull thread num, which dermine the num of threads to
+   *  distribute network data,
+   *  1. its default value is CPU num, it must be setted before producer/consumer
+   *     start, minimum value is CPU num;
+   *  2. this pullThread num must be tested on your environment to find the best
+   *     value for RT of sendMsg or delay time of consume msg before you change it;
+   *  3. producer and consumer need different pullThread num, if set this num,
+   *     producer and consumer must set different instanceName.
+   **/
+  void setTcpTransportPullThreadNum(int num);
+  const int getTcpTransportPullThreadNum() const;
+
+  /** timeout of tcp connect, it is same meaning for both producer and consumer;
+   *    1. default value is 3000ms
+   *    2. input parameter could only be milliSecond, suggestion value is
+   *       1000-3000ms;
+   **/
+  void setTcpTransportConnectTimeout(uint64_t timeout);  // ms
+  const uint64_t getTcpTransportConnectTimeout() const;
+
+  /** timeout of tryLock tcpTransport before sendMsg/pullMsg, if timeout,
+   *  returns NULL
+   *    1. paremeter unit is ms, default value is 3000ms, the minimun value is 1000ms
+   *       suggestion value is 3000ms;
+   *    2. if configured with value smaller than 1000ms, the tryLockTimeout value
+   *       will be setted to 1000ms
+   **/
+  void setTcpTransportTryLockTimeout(uint64_t timeout);  // ms
+  const uint64_t getTcpTransportTryLockTimeout() const;
+
+  void setUnitName(std::string unitName);
+  const std::string& getUnitName() const;
+  void setAsyncPull(bool asyncFlag);
+  void setSessionCredentials(const std::string& accessKey,
+                             const std::string& secretKey,
+                             const std::string& accessChannel);
+  const SessionCredentials& getSessionCredentials() const;
 
  private:
-  TaskQueue* m_pullmsgQueue;
-  std::unique_ptr<boost::thread> m_pullmsgThread;
+  DefaultMQPushConsumerImpl* impl;
 };
 //<!***************************************************************************
 }  // namespace rocketmq
diff --git a/include/MQClient.h b/include/MQClient.h
index 0e23339..d449aab 100644
--- a/include/MQClient.h
+++ b/include/MQClient.h
@@ -1,202 +1,38 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-#ifndef __MQADMIN_H__
-#define __MQADMIN_H__
-#include <boost/asio.hpp>
-#include <boost/asio/io_service.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
-#include "MQMessageExt.h"
-#include "MQMessageQueue.h"
-#include "QueryResult.h"
-#include "RocketMQClient.h"
-#include "SessionCredentials.h"
-
-namespace rocketmq {
-class MQClientFactory;
-//<!***************************************************************************
-
-enum elogLevel {
-  eLOG_LEVEL_FATAL = 1,
-  eLOG_LEVEL_ERROR = 2,
-  eLOG_LEVEL_WARN = 3,
-  eLOG_LEVEL_INFO = 4,
-  eLOG_LEVEL_DEBUG = 5,
-  eLOG_LEVEL_TRACE = 6,
-  eLOG_LEVEL_LEVEL_NUM = 7
-};
-
-class ROCKETMQCLIENT_API MQClient {
- public:
-  MQClient();
-  virtual ~MQClient();
-
- public:
-  // clientid=processId-ipAddr@instanceName;
-  std::string getMQClientId() const;
-  const std::string& getNamesrvAddr() const;
-  void setNamesrvAddr(const std::string& namesrvAddr);
-  const std::string& getNamesrvDomain() const;
-  void setNamesrvDomain(const std::string& namesrvDomain);
-  const std::string& getInstanceName() const;
-  void setInstanceName(const std::string& instanceName);
-  // nameSpace
-  const std::string& getNameSpace() const;
-  void setNameSpace(const std::string& nameSpace);
-  const std::string& getGroupName() const;
-  void setGroupName(const std::string& groupname);
-
-  /**
-   * no realization
-   */
-  void createTopic(const std::string& key, const std::string& newTopic, int queueNum);
-  /**
-   * search earliest msg store time for specified queue
-   *
-   * @param mq
-   *            message queue
-   * @return earliest store time, ms
-   */
-  int64 earliestMsgStoreTime(const MQMessageQueue& mq);
-  /**
-   * search maxOffset of queue
-   *
-   * @param mq
-   *            message queue
-   * @return minOffset of queue
-   */
-  int64 minOffset(const MQMessageQueue& mq);
-  /**
-   * search maxOffset of queue
-   * Note: maxOffset-1 is max offset that could get msg
-   * @param mq
-   *            message queue
-   * @return maxOffset of queue
-   */
-  int64 maxOffset(const MQMessageQueue& mq);
-  /**
-   * get queue offset by timestamp
-   *
-   * @param mq
-   *            mq queue
-   * @param timestamp
-   *            timestamp with ms unit
-   * @return queue offset according to timestamp
-   */
-  int64 searchOffset(const MQMessageQueue& mq, uint64_t timestamp);
-  /**
-   * get whole msg info from broker by msgId
-   *
-   * @param msgId
-   * @return MQMessageExt
-   */
-  MQMessageExt* viewMessage(const std::string& msgId);
-  /**
-   * query message by topic and key
-   *
-   * @param topic
-   *            topic name
-   * @param key
-   *            topic key
-   * @param maxNum
-   *            query num
-   * @param begin
-   *            begin timestamp
-   * @param end
-   *            end timestamp
-   * @return
-   *            according to QueryResult
-   */
-  QueryResult queryMessage(const std::string& topic, const std::string& key, int maxNum, int64 begin, int64 end);
-
-  std::vector<MQMessageQueue> getTopicMessageQueueInfo(const std::string& topic);
-
-  // log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
-  // log file num is 3, each log size is 100M
-  void setLogLevel(elogLevel inputLevel);
-  elogLevel getLogLevel();
-  void setLogFileSizeAndNum(int fileNum, long perFileSize);  // perFileSize is MB unit
-
-  /** set TcpTransport pull thread num, which dermine the num of threads to
- distribute network data,
-     1. its default value is CPU num, it must be setted before producer/consumer
- start, minimum value is CPU num;
-     2. this pullThread num must be tested on your environment to find the best
- value for RT of sendMsg or delay time of consume msg before you change it;
-     3. producer and consumer need different pullThread num, if set this num,
- producer and consumer must set different instanceName.
-     4. configuration suggestion:
-         1>. minimum RT of sendMsg:
-                 pullThreadNum = brokerNum*2
- **/
-  void setTcpTransportPullThreadNum(int num);
-  const int getTcpTransportPullThreadNum() const;
-
-  /** timeout of tcp connect, it is same meaning for both producer and consumer;
-      1. default value is 3000ms
-      2. input parameter could only be milliSecond, suggestion value is
-  1000-3000ms;
-  **/
-  void setTcpTransportConnectTimeout(uint64_t timeout);  // ms
-  const uint64_t getTcpTransportConnectTimeout() const;
-
-  /** timeout of tryLock tcpTransport before sendMsg/pullMsg, if timeout,
-  returns NULL
-      1. paremeter unit is ms, default value is 3000ms, the minimun value is
-  1000ms
-          suggestion value is 3000ms;
-      2. if configured with value smaller than 1000ms, the tryLockTimeout value
-  will be setted to 1000ms
-  **/
-  void setTcpTransportTryLockTimeout(uint64_t timeout);  // ms
-  const uint64_t getTcpTransportTryLockTimeout() const;
-
-  void setUnitName(std::string unitName);
-  const std::string& getUnitName();
-
-  void setSessionCredentials(const std::string& input_accessKey,
-                             const std::string& input_secretKey,
-                             const std::string& input_onsChannel);
-  const SessionCredentials& getSessionCredentials() const;
-
- protected:
-  virtual void start();
-  virtual void shutdown();
-  MQClientFactory* getFactory() const;
-  virtual bool isServiceStateOk();
-
- protected:
-  std::string m_namesrvAddr;
-  std::string m_namesrvDomain;
-  std::string m_instanceName;
-  std::string m_nameSpace;
-  std::string m_GroupName;
-  MQClientFactory* m_clientFactory;
-  int m_serviceState;
-  int m_pullThreadNum;
-  uint64_t m_tcpConnectTimeout;           // ms
-  uint64_t m_tcpTransportTryLockTimeout;  // s
-
-  std::string m_unitName;
-  SessionCredentials m_SessionCredentials;
-};
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#ifndef __MQADMIN_H__
+#define __MQADMIN_H__
+#include "MQMessageExt.h"
+#include "MQMessageQueue.h"
+#include "RocketMQClient.h"
+#include "SessionCredentials.h"
+
+namespace rocketmq {
+
+enum elogLevel {
+  eLOG_LEVEL_FATAL = 1,
+  eLOG_LEVEL_ERROR = 2,
+  eLOG_LEVEL_WARN = 3,
+  eLOG_LEVEL_INFO = 4,
+  eLOG_LEVEL_DEBUG = 5,
+  eLOG_LEVEL_TRACE = 6,
+  eLOG_LEVEL_LEVEL_NUM = 7
+};
+
+}  // namespace rocketmq
+#endif
diff --git a/include/TransactionMQProducer.h b/include/TransactionMQProducer.h
index fcd9a7c..2ba34db 100644
--- a/include/TransactionMQProducer.h
+++ b/include/TransactionMQProducer.h
@@ -18,29 +18,84 @@
 #ifndef __TRANSACTIONMQPRODUCER_H__
 #define __TRANSACTIONMQPRODUCER_H__
 
-#include <boost/asio.hpp>
-#include <boost/asio/io_service.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/weak_ptr.hpp>
 #include <memory>
 #include <string>
-#include "DefaultMQProducer.h"
+#include "MQClient.h"
+#include "MQMessage.h"
 #include "MQMessageExt.h"
 #include "TransactionListener.h"
 #include "TransactionSendResult.h"
 
 namespace rocketmq {
-
-class ROCKETMQCLIENT_API TransactionMQProducer : public DefaultMQProducer {
+class TransactionMQProducerImpl;
+class ROCKETMQCLIENT_API TransactionMQProducer {
  public:
-  TransactionMQProducer(const std::string& producerGroup)
-      : DefaultMQProducer(producerGroup), m_thread_num(1), m_ioServiceWork(m_ioService) {}
-  virtual ~TransactionMQProducer() {}
+  TransactionMQProducer(const std::string& producerGroup);
+  virtual ~TransactionMQProducer();
   void start();
   void shutdown();
-  std::shared_ptr<TransactionListener> getTransactionListener() { return m_transactionListener; }
-  void setTransactionListener(TransactionListener* listener) { m_transactionListener.reset(listener); }
+  const std::string& getNamesrvAddr() const;
+  void setNamesrvAddr(const std::string& namesrvAddr);
+  const std::string& getNamesrvDomain() const;
+  void setNamesrvDomain(const std::string& namesrvDomain);
+  const std::string& getInstanceName() const;
+  void setInstanceName(const std::string& instanceName);
+  // nameSpace
+  const std::string& getNameSpace() const;
+  void setNameSpace(const std::string& nameSpace);
+  const std::string& getGroupName() const;
+  void setGroupName(const std::string& groupname);
+  void setSessionCredentials(const std::string& accessKey,
+                             const std::string& secretKey,
+                             const std::string& accessChannel);
+  const SessionCredentials& getSessionCredentials() const;
+
+  void setUnitName(std::string unitName);
+  const std::string& getUnitName() const;
+
+  int getSendMsgTimeout() const;
+  void setSendMsgTimeout(int sendMsgTimeout);
+  void setTcpTransportPullThreadNum(int num);
+  const int getTcpTransportPullThreadNum() const;
+
+  /** timeout of tcp connect, it is same meaning for both producer and consumer;
+   *    1. default value is 3000ms
+   *    2. input parameter could only be milliSecond, suggestion value is
+   *       1000-3000ms;
+   **/
+  void setTcpTransportConnectTimeout(uint64_t timeout);  // ms
+  const uint64_t getTcpTransportConnectTimeout() const;
+
+  /** timeout of tryLock tcpTransport before sendMsg/pullMsg, if timeout,
+   *  returns NULL
+   *    1. paremeter unit is ms, default value is 3000ms, the minimun value is 1000ms
+   *       suggestion value is 3000ms;
+   *    2. if configured with value smaller than 1000ms, the tryLockTimeout value
+   *       will be setted to 1000ms
+   **/
+  void setTcpTransportTryLockTimeout(uint64_t timeout);  // ms
+  const uint64_t getTcpTransportTryLockTimeout() const;
+
+  /*
+   *  if msgBody size is large than m_compressMsgBodyOverHowmuch
+   *  rocketmq cpp will compress msgBody according to compressLevel
+   */
+  int getCompressMsgBodyOverHowmuch() const;
+  void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch);
+  int getCompressLevel() const;
+  void setCompressLevel(int compressLevel);
+
+  // if msgbody size larger than maxMsgBodySize, exception will be throwed
+  int getMaxMessageSize() const;
+  void setMaxMessageSize(int maxMessageSize);
+  // log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
+  // log file num is 3, each log size is 100M
+  void setLogLevel(elogLevel inputLevel);
+  elogLevel getLogLevel();
+  void setLogFileSizeAndNum(int fileNum, long perFileSize);  // perFileSize is MB unit
+
+  std::shared_ptr<TransactionListener> getTransactionListener();
+  void setTransactionListener(TransactionListener* listener);
   TransactionSendResult sendMessageInTransaction(MQMessage& msg, void* arg);
   void checkTransactionState(const std::string& addr,
                              const MQMessageExt& message,
@@ -51,23 +106,7 @@ class ROCKETMQCLIENT_API TransactionMQProducer : public DefaultMQProducer {
                              const std::string& offsetMsgId);
 
  private:
-  void initTransactionEnv();
-  void destroyTransactionEnv();
-  void endTransaction(SendResult& sendResult, LocalTransactionState& localTransactionState);
-  void checkTransactionStateImpl(const std::string& addr,
-                                 const MQMessageExt& message,
-                                 long tranStateTableOffset,
-                                 long commitLogOffset,
-                                 const std::string& msgId,
-                                 const std::string& transactionId,
-                                 const std::string& offsetMsgId);
-
- private:
-  std::shared_ptr<TransactionListener> m_transactionListener;
-  int m_thread_num;
-  boost::thread_group m_threadpool;
-  boost::asio::io_service m_ioService;
-  boost::asio::io_service::work m_ioServiceWork;
+  TransactionMQProducerImpl* impl;
 };
 }  // namespace rocketmq
 
diff --git a/src/common/Arg_helper.cpp b/src/common/Arg_helper.cpp
index 61ac549..934954e 100644
--- a/src/common/Arg_helper.cpp
+++ b/src/common/Arg_helper.cpp
@@ -64,4 +64,4 @@ string Arg_helper::get_option_value(string opt_) const {
 }
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
diff --git a/src/common/AsyncArg.h b/src/common/AsyncArg.h
index fc358cb..a683e6d 100644
--- a/src/common/AsyncArg.h
+++ b/src/common/AsyncArg.h
@@ -1,36 +1,36 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-#ifndef _AsyncArg_H_
-#define _AsyncArg_H_
-
-#include "MQMessageQueue.h"
-#include "PullAPIWrapper.h"
-#include "SubscriptionData.h"
-
-namespace rocketmq {
-//<!***************************************************************************
-
-struct AsyncArg {
-  MQMessageQueue mq;
-  SubscriptionData subData;
-  PullAPIWrapper* pPullWrapper;
-};
-
-//<!***************************************************************************
-}
-#endif  //<! _AsyncArg_H_
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#ifndef _AsyncArg_H_
+#define _AsyncArg_H_
+
+#include "MQMessageQueue.h"
+#include "PullAPIWrapper.h"
+#include "SubscriptionData.h"
+
+namespace rocketmq {
+//<!***************************************************************************
+
+struct AsyncArg {
+  MQMessageQueue mq;
+  SubscriptionData subData;
+  PullAPIWrapper* pPullWrapper;
+};
+
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif  //<! _AsyncArg_H_
diff --git a/src/common/AsyncCallbackWrap.h b/src/common/AsyncCallbackWrap.h
index 8802fdb..32a752f 100644
--- a/src/common/AsyncCallbackWrap.h
+++ b/src/common/AsyncCallbackWrap.h
@@ -27,7 +27,7 @@ namespace rocketmq {
 
 class ResponseFuture;
 class MQClientAPIImpl;
-class DefaultMQProducer;
+// class DefaultMQProducer;
 //<!***************************************************************************
 enum asyncCallBackType { asyncCallbackWrap = 0, sendCallbackWrap = 1, pullCallbackWrap = 2 };
 
diff --git a/src/common/ByteOrder.h b/src/common/ByteOrder.h
index 2ecb6ab..16a5184 100644
--- a/src/common/ByteOrder.h
+++ b/src/common/ByteOrder.h
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 #ifndef BYTEORDER_H_INCLUDED
 #define BYTEORDER_H_INCLUDED
 
@@ -213,5 +213,5 @@ inline void ByteOrder::bigEndian24BitToChars(const int value, void* const destBy
   static_cast<uint8*>(destBytes)[1] = (uint8)(value >> 8);
   static_cast<uint8*>(destBytes)[2] = (uint8)value;
 }
-}
+}  // namespace rocketmq
 #endif  // BYTEORDER_H_INCLUDED
diff --git a/src/common/ClientRPCHook.cpp b/src/common/ClientRPCHook.cpp
index cd216d1..fc013da 100644
--- a/src/common/ClientRPCHook.cpp
+++ b/src/common/ClientRPCHook.cpp
@@ -72,4 +72,4 @@ void ClientRPCHook::doBeforeRequest(const string& remoteAddr, RemotingCommand& r
     LOG_ERROR("signature for request failed");
   }
 }
-}
+}  // namespace rocketmq
diff --git a/src/common/ClientRPCHook.h b/src/common/ClientRPCHook.h
index 72e2f76..52fef30 100644
--- a/src/common/ClientRPCHook.h
+++ b/src/common/ClientRPCHook.h
@@ -41,5 +41,5 @@ class ClientRPCHook : public RPCHook {
 
   virtual void doAfterResponse(RemotingCommand& request, RemotingCommand& response) {}
 };
-}
+}  // namespace rocketmq
 #endif
diff --git a/src/common/CommunicationMode.h b/src/common/CommunicationMode.h
index 6ba947a..b2cb601 100644
--- a/src/common/CommunicationMode.h
+++ b/src/common/CommunicationMode.h
@@ -23,5 +23,5 @@ namespace rocketmq {
 enum CommunicationMode { ComMode_SYNC, ComMode_ASYNC, ComMode_ONEWAY };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/MQClient.cpp b/src/common/DefaultMQClient.cpp
similarity index 64%
rename from src/common/MQClient.cpp
rename to src/common/DefaultMQClient.cpp
index f638f6f..aad0981 100644
--- a/src/common/MQClient.cpp
+++ b/src/common/DefaultMQClient.cpp
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-#include "MQClient.h"
+#include "include/DefaultMQClient.h"
 #include "Logging.h"
 #include "MQClientFactory.h"
 #include "MQClientManager.h"
@@ -31,7 +31,7 @@ namespace rocketmq {
 const char* rocketmq_build_time = "VERSION: " ROCKETMQCPP_VERSION ", BUILD DATE: " BUILD_DATE " ";
 
 //<!************************************************************************
-MQClient::MQClient() {
+DefaultMQClient::DefaultMQClient() {
   string NAMESRV_ADDR_ENV = "NAMESRV_ADDR";
   if (const char* addr = getenv(NAMESRV_ADDR_ENV.c_str()))
     m_namesrvAddr = addr;
@@ -48,9 +48,9 @@ MQClient::MQClient() {
   m_unitName = "";
 }
 
-MQClient::~MQClient() {}
+DefaultMQClient::~DefaultMQClient() {}
 
-string MQClient::getMQClientId() const {
+string DefaultMQClient::getMQClientId() const {
   string clientIP = UtilAll::getLocalAddress();
   string processId = UtilAll::to_string(getpid());
   // return processId + "-" + clientIP + "@" + m_instanceName;
@@ -58,45 +58,45 @@ string MQClient::getMQClientId() const {
 }
 
 //<!groupName;
-const string& MQClient::getGroupName() const {
+const string& DefaultMQClient::getGroupName() const {
   return m_GroupName;
 }
 
-void MQClient::setGroupName(const string& groupname) {
+void DefaultMQClient::setGroupName(const string& groupname) {
   m_GroupName = groupname;
 }
 
-const string& MQClient::getNamesrvAddr() const {
+const string& DefaultMQClient::getNamesrvAddr() const {
   return m_namesrvAddr;
 }
 
-void MQClient::setNamesrvAddr(const string& namesrvAddr) {
+void DefaultMQClient::setNamesrvAddr(const string& namesrvAddr) {
   m_namesrvAddr = NameSpaceUtil::formatNameServerURL(namesrvAddr);
 }
 
-const string& MQClient::getNamesrvDomain() const {
+const string& DefaultMQClient::getNamesrvDomain() const {
   return m_namesrvDomain;
 }
 
-void MQClient::setNamesrvDomain(const string& namesrvDomain) {
+void DefaultMQClient::setNamesrvDomain(const string& namesrvDomain) {
   m_namesrvDomain = namesrvDomain;
 }
 
-const string& MQClient::getInstanceName() const {
+const string& DefaultMQClient::getInstanceName() const {
   return m_instanceName;
 }
 
-void MQClient::setInstanceName(const string& instanceName) {
+void DefaultMQClient::setInstanceName(const string& instanceName) {
   m_instanceName = instanceName;
 }
-const string& MQClient::getNameSpace() const {
+const string& DefaultMQClient::getNameSpace() const {
   return m_nameSpace;
 }
 
-void MQClient::setNameSpace(const string& nameSpace) {
+void DefaultMQClient::setNameSpace(const string& nameSpace) {
   m_nameSpace = nameSpace;
 }
-void MQClient::createTopic(const string& key, const string& newTopic, int queueNum) {
+void DefaultMQClient::createTopic(const string& key, const string& newTopic, int queueNum) {
   try {
     getFactory()->createTopic(key, newTopic, queueNum, m_SessionCredentials);
   } catch (MQException& e) {
@@ -104,31 +104,31 @@ void MQClient::createTopic(const string& key, const string& newTopic, int queueN
   }
 }
 
-int64 MQClient::earliestMsgStoreTime(const MQMessageQueue& mq) {
+int64 DefaultMQClient::earliestMsgStoreTime(const MQMessageQueue& mq) {
   return getFactory()->earliestMsgStoreTime(mq, m_SessionCredentials);
 }
 
-QueryResult MQClient::queryMessage(const string& topic, const string& key, int maxNum, int64 begin, int64 end) {
+QueryResult DefaultMQClient::queryMessage(const string& topic, const string& key, int maxNum, int64 begin, int64 end) {
   return getFactory()->queryMessage(topic, key, maxNum, begin, end, m_SessionCredentials);
 }
 
-int64 MQClient::minOffset(const MQMessageQueue& mq) {
+int64 DefaultMQClient::minOffset(const MQMessageQueue& mq) {
   return getFactory()->minOffset(mq, m_SessionCredentials);
 }
 
-int64 MQClient::maxOffset(const MQMessageQueue& mq) {
+int64 DefaultMQClient::maxOffset(const MQMessageQueue& mq) {
   return getFactory()->maxOffset(mq, m_SessionCredentials);
 }
 
-int64 MQClient::searchOffset(const MQMessageQueue& mq, uint64_t timestamp) {
+int64 DefaultMQClient::searchOffset(const MQMessageQueue& mq, uint64_t timestamp) {
   return getFactory()->searchOffset(mq, timestamp, m_SessionCredentials);
 }
 
-MQMessageExt* MQClient::viewMessage(const string& msgId) {
+MQMessageExt* DefaultMQClient::viewMessage(const string& msgId) {
   return getFactory()->viewMessage(msgId, m_SessionCredentials);
 }
 
-vector<MQMessageQueue> MQClient::getTopicMessageQueueInfo(const string& topic) {
+vector<MQMessageQueue> DefaultMQClient::getTopicMessageQueueInfo(const string& topic) {
   boost::weak_ptr<TopicPublishInfo> weak_topicPublishInfo(
       getFactory()->tryToFindTopicPublishInfo(topic, m_SessionCredentials));
   boost::shared_ptr<TopicPublishInfo> topicPublishInfo(weak_topicPublishInfo.lock());
@@ -138,7 +138,7 @@ vector<MQMessageQueue> MQClient::getTopicMessageQueueInfo(const string& topic) {
   THROW_MQEXCEPTION(MQClientException, "could not find MessageQueue Info of topic: [" + topic + "].", -1);
 }
 
-void MQClient::start() {
+void DefaultMQClient::start() {
   if (getFactory() == NULL) {
     m_clientFactory = MQClientManager::getInstance()->getMQClientFactory(
         getMQClientId(), m_pullThreadNum, m_tcpConnectTimeout, m_tcpTransportTryLockTimeout, m_unitName);
@@ -149,74 +149,74 @@ void MQClient::start() {
       getGroupName().c_str(), getMQClientId().c_str(), getInstanceName().c_str(), getNamesrvAddr().c_str());
 }
 
-void MQClient::shutdown() {
+void DefaultMQClient::shutdown() {
   m_clientFactory->shutdown();
   m_clientFactory = NULL;
 }
 
-MQClientFactory* MQClient::getFactory() const {
+MQClientFactory* DefaultMQClient::getFactory() const {
   return m_clientFactory;
 }
 
-bool MQClient::isServiceStateOk() {
+bool DefaultMQClient::isServiceStateOk() {
   return m_serviceState == RUNNING;
 }
 
-void MQClient::setLogLevel(elogLevel inputLevel) {
+void DefaultMQClient::setLogLevel(elogLevel inputLevel) {
   ALOG_ADAPTER->setLogLevel(inputLevel);
 }
 
-elogLevel MQClient::getLogLevel() {
+elogLevel DefaultMQClient::getLogLevel() {
   return ALOG_ADAPTER->getLogLevel();
 }
 
-void MQClient::setLogFileSizeAndNum(int fileNum, long perFileSize) {
+void DefaultMQClient::setLogFileSizeAndNum(int fileNum, long perFileSize) {
   ALOG_ADAPTER->setLogFileNumAndSize(fileNum, perFileSize);
 }
 
-void MQClient::setTcpTransportPullThreadNum(int num) {
+void DefaultMQClient::setTcpTransportPullThreadNum(int num) {
   if (num > m_pullThreadNum) {
     m_pullThreadNum = num;
   }
 }
 
-const int MQClient::getTcpTransportPullThreadNum() const {
+const int DefaultMQClient::getTcpTransportPullThreadNum() const {
   return m_pullThreadNum;
 }
 
-void MQClient::setTcpTransportConnectTimeout(uint64_t timeout) {
+void DefaultMQClient::setTcpTransportConnectTimeout(uint64_t timeout) {
   m_tcpConnectTimeout = timeout;
 }
-const uint64_t MQClient::getTcpTransportConnectTimeout() const {
+const uint64_t DefaultMQClient::getTcpTransportConnectTimeout() const {
   return m_tcpConnectTimeout;
 }
 
-void MQClient::setTcpTransportTryLockTimeout(uint64_t timeout) {
+void DefaultMQClient::setTcpTransportTryLockTimeout(uint64_t timeout) {
   if (timeout < 1000) {
     timeout = 1000;
   }
   m_tcpTransportTryLockTimeout = timeout / 1000;
 }
-const uint64_t MQClient::getTcpTransportTryLockTimeout() const {
+const uint64_t DefaultMQClient::getTcpTransportTryLockTimeout() const {
   return m_tcpTransportTryLockTimeout;
 }
 
-void MQClient::setUnitName(string unitName) {
+void DefaultMQClient::setUnitName(string unitName) {
   m_unitName = unitName;
 }
-const string& MQClient::getUnitName() {
+const string& DefaultMQClient::getUnitName() const {
   return m_unitName;
 }
 
-void MQClient::setSessionCredentials(const string& input_accessKey,
-                                     const string& input_secretKey,
-                                     const string& input_onsChannel) {
+void DefaultMQClient::setSessionCredentials(const string& input_accessKey,
+                                            const string& input_secretKey,
+                                            const string& input_onsChannel) {
   m_SessionCredentials.setAccessKey(input_accessKey);
   m_SessionCredentials.setSecretKey(input_secretKey);
   m_SessionCredentials.setAuthChannel(input_onsChannel);
 }
 
-const SessionCredentials& MQClient::getSessionCredentials() const {
+const SessionCredentials& DefaultMQClient::getSessionCredentials() const {
   return m_SessionCredentials;
 }
 
diff --git a/src/common/FilterAPI.h b/src/common/FilterAPI.h
index d632bc2..77255ba 100644
--- a/src/common/FilterAPI.h
+++ b/src/common/FilterAPI.h
@@ -57,5 +57,5 @@ class FilterAPI {
 };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/InputStream.cpp b/src/common/InputStream.cpp
index f807d6b..dbd011a 100644
--- a/src/common/InputStream.cpp
+++ b/src/common/InputStream.cpp
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "InputStream.h"
 #include <algorithm>
 #include "MemoryOutputStream.h"
@@ -108,4 +108,4 @@ void InputStream::skipNextBytes(int64 numBytesToSkip) {
     std::free(temp);
   }
 }
-}
+}  // namespace rocketmq
diff --git a/src/common/InputStream.h b/src/common/InputStream.h
index 8c6ddb5..8cf1b84 100644
--- a/src/common/InputStream.h
+++ b/src/common/InputStream.h
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 
 #ifndef INPUTSTREAM_H_INCLUDED
 #define INPUTSTREAM_H_INCLUDED
@@ -190,5 +190,5 @@ class ROCKETMQCLIENT_API InputStream {
   //==============================================================================
   InputStream() {}
 };
-}
+}  // namespace rocketmq
 #endif  // INPUTSTREAM_H_INCLUDED
diff --git a/src/common/MemoryInputStream.cpp b/src/common/MemoryInputStream.cpp
index 3d65992..b857c44 100644
--- a/src/common/MemoryInputStream.cpp
+++ b/src/common/MemoryInputStream.cpp
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "MemoryInputStream.h"
 
 namespace rocketmq {
@@ -72,4 +72,4 @@ bool MemoryInputStream::setPosition(const int64 pos) {
 int64 MemoryInputStream::getPosition() {
   return (int64)position;
 }
-}
+}  // namespace rocketmq
diff --git a/src/common/MemoryInputStream.h b/src/common/MemoryInputStream.h
index 53584b9..2d3a365 100644
--- a/src/common/MemoryInputStream.h
+++ b/src/common/MemoryInputStream.h
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 
 #ifndef MEMORYINPUTSTREAM_H_INCLUDED
 #define MEMORYINPUTSTREAM_H_INCLUDED
@@ -92,5 +92,5 @@ class ROCKETMQCLIENT_API MemoryInputStream : public InputStream {
 
   void createInternalCopy();
 };
-}
+}  // namespace rocketmq
 #endif
diff --git a/src/common/MemoryOutputStream.cpp b/src/common/MemoryOutputStream.cpp
index 9578c8a..d7366f5 100644
--- a/src/common/MemoryOutputStream.cpp
+++ b/src/common/MemoryOutputStream.cpp
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "MemoryOutputStream.h"
 
 namespace rocketmq {
@@ -153,4 +153,4 @@ OutputStream& operator<<(OutputStream& stream, const MemoryOutputStream& streamT
 
   return stream;
 }
-}
+}  // namespace rocketmq
diff --git a/src/common/MemoryOutputStream.h b/src/common/MemoryOutputStream.h
index 4b39879..cc3245a 100644
--- a/src/common/MemoryOutputStream.h
+++ b/src/common/MemoryOutputStream.h
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 
 #ifndef MEMORYOUTPUTSTREAM_H_INCLUDED
 #define MEMORYOUTPUTSTREAM_H_INCLUDED
@@ -126,5 +126,5 @@ class ROCKETMQCLIENT_API MemoryOutputStream : public OutputStream {
 /** Copies all the data that has been written to a MemoryOutputStream into
  * another stream. */
 OutputStream& operator<<(OutputStream& stream, const MemoryOutputStream& streamToRead);
-}
+}  // namespace rocketmq
 #endif  // MEMORYOUTPUTSTREAM_H_INCLUDED
diff --git a/src/common/MessageSysFlag.cpp b/src/common/MessageSysFlag.cpp
index 50a28b4..732f1d5 100644
--- a/src/common/MessageSysFlag.cpp
+++ b/src/common/MessageSysFlag.cpp
@@ -34,4 +34,4 @@ int MessageSysFlag::resetTransactionValue(int flag, int type) {
 }
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
diff --git a/src/common/MessageSysFlag.h b/src/common/MessageSysFlag.h
index d7f7993..3652d23 100644
--- a/src/common/MessageSysFlag.h
+++ b/src/common/MessageSysFlag.h
@@ -34,5 +34,5 @@ class MessageSysFlag {
 };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/OutputStream.cpp b/src/common/OutputStream.cpp
index 2a056d3..78b60c4 100644
--- a/src/common/OutputStream.cpp
+++ b/src/common/OutputStream.cpp
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "OutputStream.h"
 #include <limits>
 #include "big_endian.h"
@@ -101,4 +101,4 @@ int64 OutputStream::writeFromInputStream(InputStream& source, int64 numBytesToWr
 
   return numWritten;
 }
-}
+}  // namespace rocketmq
diff --git a/src/common/OutputStream.h b/src/common/OutputStream.h
index 3792169..6dd459d 100644
--- a/src/common/OutputStream.h
+++ b/src/common/OutputStream.h
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 
 #ifndef OUTPUTSTREAM_H_INCLUDED
 #define OUTPUTSTREAM_H_INCLUDED
@@ -143,6 +143,6 @@ class ROCKETMQCLIENT_API OutputStream {
   */
   virtual int64 writeFromInputStream(InputStream& source, int64 maxNumBytesToWrite);
 };
-}
+}  // namespace rocketmq
 
 #endif  // OUTPUTSTREAM_H_INCLUDED
diff --git a/src/common/PermName.cpp b/src/common/PermName.cpp
index bd36bfc..7484cc6 100644
--- a/src/common/PermName.cpp
+++ b/src/common/PermName.cpp
@@ -54,4 +54,4 @@ string PermName::perm2String(int perm) {
 }
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
diff --git a/src/common/PermName.h b/src/common/PermName.h
index 6556382..8b6f23b 100644
--- a/src/common/PermName.h
+++ b/src/common/PermName.h
@@ -35,5 +35,5 @@ class PermName {
 };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/PullSysFlag.cpp b/src/common/PullSysFlag.cpp
index a4af97a..cb26dac 100644
--- a/src/common/PullSysFlag.cpp
+++ b/src/common/PullSysFlag.cpp
@@ -66,4 +66,4 @@ bool PullSysFlag::hasClassFilterFlag(int sysFlag) {
 }
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
diff --git a/src/common/PullSysFlag.h b/src/common/PullSysFlag.h
index 37fcd89..d439d7d 100644
--- a/src/common/PullSysFlag.h
+++ b/src/common/PullSysFlag.h
@@ -36,5 +36,5 @@ class PullSysFlag {
 };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/ServiceState.h b/src/common/ServiceState.h
index a8ae792..cfa7bc6 100644
--- a/src/common/ServiceState.h
+++ b/src/common/ServiceState.h
@@ -21,5 +21,5 @@ namespace rocketmq {
 enum ServiceState { CREATE_JUST, RUNNING, SHUTDOWN_ALREADY, START_FAILED };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/SubscriptionGroupConfig.h b/src/common/SubscriptionGroupConfig.h
index 9a54140..964b64c 100644
--- a/src/common/SubscriptionGroupConfig.h
+++ b/src/common/SubscriptionGroupConfig.h
@@ -45,5 +45,5 @@ class SubscriptionGroupConfig {
 };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/TopAddressing.cpp b/src/common/TopAddressing.cpp
index 41f7b72..9d94c43 100644
--- a/src/common/TopAddressing.cpp
+++ b/src/common/TopAddressing.cpp
@@ -102,4 +102,4 @@ string TopAddressing::clearNewLine(const string& str) {
 
   return newString;
 }
-}  //<!end namespace;
+}  // namespace rocketmq
diff --git a/src/common/TopicConfig.cpp b/src/common/TopicConfig.cpp
index 9f01199..38ea138 100644
--- a/src/common/TopicConfig.cpp
+++ b/src/common/TopicConfig.cpp
@@ -111,4 +111,4 @@ void TopicConfig::setTopicFilterType(TopicFilterType topicFilterType) {
   m_topicFilterType = topicFilterType;
 }
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
diff --git a/src/common/TopicConfig.h b/src/common/TopicConfig.h
index 32178c9..cfdc785 100644
--- a/src/common/TopicConfig.h
+++ b/src/common/TopicConfig.h
@@ -56,5 +56,5 @@ class TopicConfig {
   TopicFilterType m_topicFilterType;
 };
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/TopicFilterType.h b/src/common/TopicFilterType.h
index 9055003..055d112 100644
--- a/src/common/TopicFilterType.h
+++ b/src/common/TopicFilterType.h
@@ -30,5 +30,5 @@ enum TopicFilterType {
   MULTI_TAG
 };
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/UtilAll.cpp b/src/common/UtilAll.cpp
index df3ec0b..c2f9563 100644
--- a/src/common/UtilAll.cpp
+++ b/src/common/UtilAll.cpp
@@ -353,4 +353,4 @@ bool UtilAll::ReplaceFile(const std::string& from_path, const std::string& to_pa
   return false;
 #endif
 }
-}
+}  // namespace rocketmq
diff --git a/src/common/UtilAll.h b/src/common/UtilAll.h
index 98fc906..a2993cf 100644
--- a/src/common/UtilAll.h
+++ b/src/common/UtilAll.h
@@ -139,5 +139,5 @@ class UtilAll {
   static std::string s_localIpAddress;
 };
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/Validators.cpp b/src/common/Validators.cpp
index 8743a20..5a7594b 100644
--- a/src/common/Validators.cpp
+++ b/src/common/Validators.cpp
@@ -101,4 +101,4 @@ void Validators::checkMessage(const MQMessage& msg, int maxMessageSize) {
 }
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
diff --git a/src/common/Validators.h b/src/common/Validators.h
index cc03fb5..c59f1bf 100644
--- a/src/common/Validators.h
+++ b/src/common/Validators.h
@@ -37,5 +37,5 @@ class Validators {
 };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/VirtualEnvUtil.h b/src/common/VirtualEnvUtil.h
index 7edc4eb..26ae898 100644
--- a/src/common/VirtualEnvUtil.h
+++ b/src/common/VirtualEnvUtil.h
@@ -30,5 +30,5 @@ class VirtualEnvUtil {
 };
 
 //<!***************************************************************************
-}  //<!end namespace;
+}  // namespace rocketmq
 #endif
diff --git a/src/common/big_endian.cpp b/src/common/big_endian.cpp
index abb4a97..52c48c0 100644
--- a/src/common/big_endian.cpp
+++ b/src/common/big_endian.cpp
@@ -93,4 +93,4 @@ bool BigEndianWriter::WriteU64(uint64_t value) {
   return Write(value);
 }
 
-}  // namespace base
+}  // namespace rocketmq
diff --git a/src/common/big_endian.h b/src/common/big_endian.h
index b7729e5..57077ee 100644
--- a/src/common/big_endian.h
+++ b/src/common/big_endian.h
@@ -97,6 +97,6 @@ class BigEndianWriter {
   char* end_;
 };
 
-}  // namespace base
+}  // namespace rocketmq
 
 #endif  // BASE_BIG_ENDIAN_H_
diff --git a/src/common/dataBlock.cpp b/src/common/dataBlock.cpp
index daca4e4..87e98af 100644
--- a/src/common/dataBlock.cpp
+++ b/src/common/dataBlock.cpp
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "dataBlock.h"
 #include <algorithm>
 
@@ -204,4 +204,4 @@ void MemoryBlock::copyTo(void* const dst, int offset, int num) const {
   if (num > 0)
     memcpy(d, data + offset, num);
 }
-}
+}  // namespace rocketmq
diff --git a/src/common/dataBlock.h b/src/common/dataBlock.h
index 4419af3..7472927 100644
--- a/src/common/dataBlock.h
+++ b/src/common/dataBlock.h
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 #ifndef __DATABLOCK_H__
 #define __DATABLOCK_H__
 
@@ -203,6 +203,6 @@ class ROCKETMQCLIENT_API MemoryBlock {
   int size;
   char* data;
 };
-}
+}  // namespace rocketmq
 
 #endif
diff --git a/src/common/sync_http_client.cpp b/src/common/sync_http_client.cpp
index 78f0292..52137b3 100644
--- a/src/common/sync_http_client.cpp
+++ b/src/common/sync_http_client.cpp
@@ -26,9 +26,9 @@
 #include "Logging.h"
 #include "url.h"
 
-using boost::lambda::var;
-using boost::asio::ip::tcp;
 using boost::asio::deadline_timer;
+using boost::asio::ip::tcp;
+using boost::lambda::var;
 
 namespace {
 void check_deadline(deadline_timer* deadline, tcp::socket* socket, const boost::system::error_code& ec) {
@@ -148,4 +148,4 @@ bool SyncfetchNsAddr(const Url& url_s, std::string& body) {
 
   return ret;
 }
-}  // end of namespace ons
+}  // namespace rocketmq
diff --git a/src/common/sync_http_client.h b/src/common/sync_http_client.h
index 9836605..1bf55fa 100644
--- a/src/common/sync_http_client.h
+++ b/src/common/sync_http_client.h
@@ -24,6 +24,6 @@ class Url;
 
 extern bool SyncfetchNsAddr(const Url& url_s, std::string& body);
 
-}  // namespace ons
+}  // namespace rocketmq
 
 #endif  // ROCKETMQ_CLIENT4CPP__SYNC_HTTP_CLIENT_H_
diff --git a/src/common/url.cpp b/src/common/url.cpp
index f8d9155..d632037 100644
--- a/src/common/url.cpp
+++ b/src/common/url.cpp
@@ -62,4 +62,4 @@ void Url::parse(const std::string& url_s) {
   query_.assign(query_i, url_s.end());
 }
 
-}  // namespace ons
+}  // namespace rocketmq
diff --git a/src/common/url.h b/src/common/url.h
index 0fbcb85..62d86a2 100644
--- a/src/common/url.h
+++ b/src/common/url.h
@@ -34,5 +34,5 @@ class Url {
   std::string path_;
   std::string query_;
 };
-}
+}  // namespace rocketmq
 #endif  // ROCKETMQ_CLIENT4CPP_URL_HH_
diff --git a/src/consumer/ConsumeMsgService.h b/src/consumer/ConsumeMsgService.h
index a6c7206..8745bae 100644
--- a/src/consumer/ConsumeMsgService.h
+++ b/src/consumer/ConsumeMsgService.h
@@ -24,12 +24,13 @@
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/thread/thread.hpp>
+#include "DefaultMQPushConsumerImpl.h"
 #include "Logging.h"
+#include "MQConsumer.h"
 #include "MQMessageListener.h"
 #include "PullRequest.h"
-
 namespace rocketmq {
-class MQConsumer;
+// class MQConsumer;
 //<!***************************************************************************
 class ConsumeMsgService {
  public:
diff --git a/src/consumer/DefaultMQPullConsumer.cpp b/src/consumer/DefaultMQPullConsumer.cpp
index 1f58e86..b6998f3 100644
--- a/src/consumer/DefaultMQPullConsumer.cpp
+++ b/src/consumer/DefaultMQPullConsumer.cpp
@@ -16,404 +16,161 @@
  */
 
 #include "DefaultMQPullConsumer.h"
-#include "AsyncArg.h"
-#include "CommunicationMode.h"
-#include "FilterAPI.h"
-#include "Logging.h"
-#include "MQClientFactory.h"
-#include "MessageAccessor.h"
-#include "NameSpaceUtil.h"
-#include "OffsetStore.h"
-#include "PullAPIWrapper.h"
-#include "PullSysFlag.h"
-#include "Rebalance.h"
-#include "Validators.h"
+#include "DefaultMQPullConsumerImpl.h"
 
 namespace rocketmq {
-//<!***************************************************************************
-DefaultMQPullConsumer::DefaultMQPullConsumer(const string& groupname)
-    : m_pMessageQueueListener(NULL),
-      m_pOffsetStore(NULL),
-      m_pRebalance(NULL),
-      m_pPullAPIWrapper(NULL)
 
-{
-  //<!set default group name;
-  string gname = groupname.empty() ? DEFAULT_CONSUMER_GROUP : groupname;
-  setGroupName(gname);
-
-  setMessageModel(CLUSTERING);
+DefaultMQPullConsumer::DefaultMQPullConsumer(const std::string& groupName) {
+  impl = new DefaultMQPullConsumerImpl(groupName);
 }
 
 DefaultMQPullConsumer::~DefaultMQPullConsumer() {
-  m_pMessageQueueListener = NULL;
-  deleteAndZero(m_pRebalance);
-  deleteAndZero(m_pOffsetStore);
-  deleteAndZero(m_pPullAPIWrapper);
+  delete impl;
 }
-
-// MQConsumer
-//<!************************************************************************
 void DefaultMQPullConsumer::start() {
-#ifndef WIN32
-  /* Ignore the SIGPIPE */
-  struct sigaction sa;
-  memset(&sa, 0, sizeof(struct sigaction));
-  sa.sa_handler = SIG_IGN;
-  sa.sa_flags = 0;
-  sigaction(SIGPIPE, &sa, 0);
-#endif
-  dealWithNameSpace();
-  switch (m_serviceState) {
-    case CREATE_JUST: {
-      m_serviceState = START_FAILED;
-      MQClient::start();
-      LOG_INFO("DefaultMQPullConsumer:%s start", m_GroupName.c_str());
-
-      //<!create rebalance;
-      m_pRebalance = new RebalancePull(this, getFactory());
-
-      string groupname = getGroupName();
-      m_pPullAPIWrapper = new PullAPIWrapper(getFactory(), groupname);
-
-      //<!data;
-      checkConfig();
-      copySubscription();
-
-      //<! registe;
-      bool registerOK = getFactory()->registerConsumer(this);
-      if (!registerOK) {
-        m_serviceState = CREATE_JUST;
-        THROW_MQEXCEPTION(
-            MQClientException,
-            "The cousumer group[" + getGroupName() + "] has been created before, specify another name please.", -1);
-      }
-
-      //<!msg model;
-      switch (getMessageModel()) {
-        case BROADCASTING:
-          m_pOffsetStore = new LocalFileOffsetStore(groupname, getFactory());
-          break;
-        case CLUSTERING:
-          m_pOffsetStore = new RemoteBrokerOffsetStore(groupname, getFactory());
-          break;
-      }
-      bool bStartFailed = false;
-      string errorMsg;
-      try {
-        m_pOffsetStore->load();
-      } catch (MQClientException& e) {
-        bStartFailed = true;
-        errorMsg = std::string(e.what());
-      }
-
-      getFactory()->start();
-      m_serviceState = RUNNING;
-      if (bStartFailed) {
-        shutdown();
-        THROW_MQEXCEPTION(MQClientException, errorMsg, -1);
-      }
-      break;
-    }
-    case RUNNING:
-    case START_FAILED:
-    case SHUTDOWN_ALREADY:
-      break;
-    default:
-      break;
-  }
+  impl->start();
 }
 
 void DefaultMQPullConsumer::shutdown() {
-  switch (m_serviceState) {
-    case RUNNING: {
-      LOG_INFO("DefaultMQPullConsumer:%s shutdown", m_GroupName.c_str());
-      persistConsumerOffset();
-      getFactory()->unregisterConsumer(this);
-      getFactory()->shutdown();
-      m_serviceState = SHUTDOWN_ALREADY;
-      break;
-    }
-    case SHUTDOWN_ALREADY:
-    case CREATE_JUST:
-      break;
-    default:
-      break;
-  }
+  impl->shutdown();
 }
 
-bool DefaultMQPullConsumer::sendMessageBack(MQMessageExt& msg, int delayLevel, string& brokerName) {
-  return true;
+// start mqclient set
+const std::string& DefaultMQPullConsumer::getNamesrvAddr() const {
+  return impl->getNamesrvAddr();
 }
 
-void DefaultMQPullConsumer::fetchSubscribeMessageQueues(const string& topic, vector<MQMessageQueue>& mqs) {
-  mqs.clear();
-  try {
-    const string localTopic = NameSpaceUtil::withNameSpace(topic, getNameSpace());
-    getFactory()->fetchSubscribeMessageQueues(localTopic, mqs, getSessionCredentials());
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-  }
+void DefaultMQPullConsumer::setNamesrvAddr(const std::string& namesrvAddr) {
+  impl->setNamesrvAddr(namesrvAddr);
 }
 
-void DefaultMQPullConsumer::updateTopicSubscribeInfo(const string& topic, vector<MQMessageQueue>& info) {}
-
-void DefaultMQPullConsumer::registerMessageQueueListener(const string& topic, MQueueListener* pListener) {
-  m_registerTopics.insert(topic);
-  if (pListener) {
-    m_pMessageQueueListener = pListener;
-  }
+const std::string& DefaultMQPullConsumer::getNamesrvDomain() const {
+  return impl->getNamesrvDomain();
 }
 
-PullResult DefaultMQPullConsumer::pull(const MQMessageQueue& mq,
-                                       const string& subExpression,
-                                       int64 offset,
-                                       int maxNums) {
-  return pullSyncImpl(mq, subExpression, offset, maxNums, false);
+void DefaultMQPullConsumer::setNamesrvDomain(const std::string& namesrvDomain) {
+  impl->setNamesrvDomain(namesrvDomain);
 }
-
-void DefaultMQPullConsumer::pull(const MQMessageQueue& mq,
-                                 const string& subExpression,
-                                 int64 offset,
-                                 int maxNums,
-                                 PullCallback* pPullCallback) {
-  pullAsyncImpl(mq, subExpression, offset, maxNums, false, pPullCallback);
+void DefaultMQPullConsumer::setSessionCredentials(const std::string& accessKey,
+                                                  const std::string& secretKey,
+                                                  const std::string& accessChannel) {
+  impl->setSessionCredentials(accessKey, secretKey, accessChannel);
 }
 
-PullResult DefaultMQPullConsumer::pullBlockIfNotFound(const MQMessageQueue& mq,
-                                                      const string& subExpression,
-                                                      int64 offset,
-                                                      int maxNums) {
-  return pullSyncImpl(mq, subExpression, offset, maxNums, true);
+const SessionCredentials& DefaultMQPullConsumer::getSessionCredentials() const {
+  return impl->getSessionCredentials();
 }
-
-void DefaultMQPullConsumer::pullBlockIfNotFound(const MQMessageQueue& mq,
-                                                const string& subExpression,
-                                                int64 offset,
-                                                int maxNums,
-                                                PullCallback* pPullCallback) {
-  pullAsyncImpl(mq, subExpression, offset, maxNums, true, pPullCallback);
+const std::string& DefaultMQPullConsumer::getInstanceName() const {
+  return impl->getInstanceName();
 }
 
-PullResult DefaultMQPullConsumer::pullSyncImpl(const MQMessageQueue& mq,
-                                               const string& subExpression,
-                                               int64 offset,
-                                               int maxNums,
-                                               bool block) {
-  if (offset < 0)
-    THROW_MQEXCEPTION(MQClientException, "offset < 0", -1);
-
-  if (maxNums <= 0)
-    THROW_MQEXCEPTION(MQClientException, "maxNums <= 0", -1);
-
-  //<!auto subscript,all sub;
-  subscriptionAutomatically(mq.getTopic());
-
-  int sysFlag = PullSysFlag::buildSysFlag(false, block, true, false);
-
-  //<!this sub;
-  unique_ptr<SubscriptionData> pSData(FilterAPI::buildSubscriptionData(mq.getTopic(), subExpression));
-
-  int timeoutMillis = block ? 1000 * 30 : 1000 * 10;
-
-  try {
-    unique_ptr<PullResult> pullResult(m_pPullAPIWrapper->pullKernelImpl(mq,                      // 1
-                                                                        pSData->getSubString(),  // 2
-                                                                        0L,                      // 3
-                                                                        offset,                  // 4
-                                                                        maxNums,                 // 5
-                                                                        sysFlag,                 // 6
-                                                                        0,                       // 7
-                                                                        1000 * 20,               // 8
-                                                                        timeoutMillis,           // 9
-                                                                        ComMode_SYNC,            // 10
-                                                                        NULL,                    //<!callback;
-                                                                        getSessionCredentials(), NULL));
-    PullResult pr = m_pPullAPIWrapper->processPullResult(mq, pullResult.get(), pSData.get());
-    if (m_useNameSpaceMode) {
-      MessageAccessor::withoutNameSpace(pr.msgFoundList, m_nameSpace);
-    }
-    return pr;
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-  }
-  return PullResult(BROKER_TIMEOUT);
+void DefaultMQPullConsumer::setInstanceName(const std::string& instanceName) {
+  impl->setInstanceName(instanceName);
 }
 
-void DefaultMQPullConsumer::pullAsyncImpl(const MQMessageQueue& mq,
-                                          const string& subExpression,
-                                          int64 offset,
-                                          int maxNums,
-                                          bool block,
-                                          PullCallback* pPullCallback) {
-  if (offset < 0)
-    THROW_MQEXCEPTION(MQClientException, "offset < 0", -1);
-
-  if (maxNums <= 0)
-    THROW_MQEXCEPTION(MQClientException, "maxNums <= 0", -1);
-
-  if (!pPullCallback)
-    THROW_MQEXCEPTION(MQClientException, "pPullCallback is null", -1);
-
-  //<!auto subscript,all sub;
-  subscriptionAutomatically(mq.getTopic());
-
-  int sysFlag = PullSysFlag::buildSysFlag(false, block, true, false);
-
-  //<!this sub;
-  unique_ptr<SubscriptionData> pSData(FilterAPI::buildSubscriptionData(mq.getTopic(), subExpression));
-
-  int timeoutMillis = block ? 1000 * 30 : 1000 * 10;
-
-  //<!�첽����;
-  AsyncArg arg;
-  arg.mq = mq;
-  arg.subData = *pSData;
-  arg.pPullWrapper = m_pPullAPIWrapper;
-
-  try {
-    // not support name space
-    unique_ptr<PullResult> pullResult(m_pPullAPIWrapper->pullKernelImpl(mq,                      // 1
-                                                                        pSData->getSubString(),  // 2
-                                                                        0L,                      // 3
-                                                                        offset,                  // 4
-                                                                        maxNums,                 // 5
-                                                                        sysFlag,                 // 6
-                                                                        0,                       // 7
-                                                                        1000 * 20,               // 8
-                                                                        timeoutMillis,           // 9
-                                                                        ComMode_ASYNC,           // 10
-                                                                        pPullCallback, getSessionCredentials(), &arg));
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-  }
+const std::string& DefaultMQPullConsumer::getNameSpace() const {
+  return impl->getNameSpace();
 }
 
-void DefaultMQPullConsumer::subscriptionAutomatically(const string& topic) {
-  SubscriptionData* pSdata = m_pRebalance->getSubscriptionData(topic);
-  if (pSdata == NULL) {
-    unique_ptr<SubscriptionData> subscriptionData(FilterAPI::buildSubscriptionData(topic, SUB_ALL));
-    m_pRebalance->setSubscriptionData(topic, subscriptionData.release());
-  }
+void DefaultMQPullConsumer::setNameSpace(const std::string& nameSpace) {
+  impl->setNameSpace(nameSpace);
 }
-
-void DefaultMQPullConsumer::updateConsumeOffset(const MQMessageQueue& mq, int64 offset) {
-  m_pOffsetStore->updateOffset(mq, offset);
+const std::string& DefaultMQPullConsumer::getGroupName() const {
+  return impl->getGroupName();
 }
 
-void DefaultMQPullConsumer::removeConsumeOffset(const MQMessageQueue& mq) {
-  m_pOffsetStore->removeOffset(mq);
+void DefaultMQPullConsumer::setGroupName(const std::string& groupName) {
+  impl->setGroupName(groupName);
 }
 
-int64 DefaultMQPullConsumer::fetchConsumeOffset(const MQMessageQueue& mq, bool fromStore) {
-  return m_pOffsetStore->readOffset(mq, fromStore ? READ_FROM_STORE : MEMORY_FIRST_THEN_STORE, getSessionCredentials());
+void DefaultMQPullConsumer::setLogLevel(elogLevel inputLevel) {
+  impl->setLogLevel(inputLevel);
 }
 
-void DefaultMQPullConsumer::persistConsumerOffset() {
-  /*As do not execute rebalance for pullConsumer now, requestTable is always
-  empty
-  map<MQMessageQueue, PullRequest*> requestTable =
-  m_pRebalance->getPullRequestTable();
-  map<MQMessageQueue, PullRequest*>::iterator it = requestTable.begin();
-  vector<MQMessageQueue> mqs;
-  for (; it != requestTable.end(); ++it)
-  {
-      if (it->second)
-      {
-          mqs.push_back(it->first);
-      }
-  }
-  m_pOffsetStore->persistAll(mqs);*/
+elogLevel DefaultMQPullConsumer::getLogLevel() {
+  return impl->getLogLevel();
 }
-
-void DefaultMQPullConsumer::persistConsumerOffsetByResetOffset() {}
-
-void DefaultMQPullConsumer::persistConsumerOffset4PullConsumer(const MQMessageQueue& mq) {
-  if (isServiceStateOk()) {
-    m_pOffsetStore->persist(mq, getSessionCredentials());
-  }
+void DefaultMQPullConsumer::setLogFileSizeAndNum(int fileNum, long perFileSize) {
+  impl->setLogFileSizeAndNum(fileNum, perFileSize);
 }
 
-void DefaultMQPullConsumer::fetchMessageQueuesInBalance(const string& topic, vector<MQMessageQueue> mqs) {}
+//    void DefaultMQPullConsumer::setUnitName(std::string unitName) {
+//        impl->setUnitName(unitName);
+//    }
+//    const std::string& DefaultMQPullConsumer::getUnitName() const {
+//        return impl->getUnitName();
+//    }
 
-void DefaultMQPullConsumer::checkConfig() {
-  string groupname = getGroupName();
-  // check consumerGroup
-  Validators::checkGroup(groupname);
-
-  // consumerGroup
-  if (!groupname.compare(DEFAULT_CONSUMER_GROUP)) {
-    THROW_MQEXCEPTION(MQClientException, "consumerGroup can not equal DEFAULT_CONSUMER", -1);
-  }
-
-  if (getMessageModel() != BROADCASTING && getMessageModel() != CLUSTERING) {
-    THROW_MQEXCEPTION(MQClientException, "messageModel is valid ", -1);
-  }
+void DefaultMQPullConsumer::fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs) {
+  impl->fetchSubscribeMessageQueues(topic, mqs);
 }
 
-void DefaultMQPullConsumer::doRebalance() {}
-
-void DefaultMQPullConsumer::copySubscription() {
-  set<string>::iterator it = m_registerTopics.begin();
-  for (; it != m_registerTopics.end(); ++it) {
-    unique_ptr<SubscriptionData> subscriptionData(FilterAPI::buildSubscriptionData((*it), SUB_ALL));
-    m_pRebalance->setSubscriptionData((*it), subscriptionData.release());
-  }
+void DefaultMQPullConsumer::persistConsumerOffset() {
+  impl->persistConsumerOffset();
+}
+void DefaultMQPullConsumer::persistConsumerOffsetByResetOffset() {
+  impl->persistConsumerOffsetByResetOffset();
+}
+void DefaultMQPullConsumer::updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info) {
+  impl->updateTopicSubscribeInfo(topic, info);
 }
-
 ConsumeType DefaultMQPullConsumer::getConsumeType() {
-  return CONSUME_ACTIVELY;
+  return impl->getConsumeType();
 }
-
 ConsumeFromWhere DefaultMQPullConsumer::getConsumeFromWhere() {
-  return CONSUME_FROM_LAST_OFFSET;
+  return impl->getConsumeFromWhere();
+}
+void DefaultMQPullConsumer::getSubscriptions(std::vector<SubscriptionData>& subData) {
+  impl->getSubscriptions(subData);
+}
+void DefaultMQPullConsumer::updateConsumeOffset(const MQMessageQueue& mq, int64 offset) {
+  impl->updateConsumeOffset(mq, offset);
+}
+void DefaultMQPullConsumer::removeConsumeOffset(const MQMessageQueue& mq) {
+  impl->removeConsumeOffset(mq);
+}
+
+void DefaultMQPullConsumer::registerMessageQueueListener(const std::string& topic, MQueueListener* pListener) {
+  impl->registerMessageQueueListener(topic, pListener);
+}
+PullResult DefaultMQPullConsumer::pull(const MQMessageQueue& mq,
+                                       const std::string& subExpression,
+                                       int64 offset,
+                                       int maxNums) {
+  return impl->pull(mq, subExpression, offset, maxNums);
+}
+void DefaultMQPullConsumer::pull(const MQMessageQueue& mq,
+                                 const std::string& subExpression,
+                                 int64 offset,
+                                 int maxNums,
+                                 PullCallback* pPullCallback) {
+  impl->pull(mq, subExpression, offset, maxNums, pPullCallback);
 }
 
-void DefaultMQPullConsumer::getSubscriptions(vector<SubscriptionData>& result) {
-  set<string>::iterator it = m_registerTopics.begin();
-  for (; it != m_registerTopics.end(); ++it) {
-    SubscriptionData ms(*it, SUB_ALL);
-    result.push_back(ms);
-  }
+PullResult DefaultMQPullConsumer::pullBlockIfNotFound(const MQMessageQueue& mq,
+                                                      const std::string& subExpression,
+                                                      int64 offset,
+                                                      int maxNums) {
+  return impl->pullBlockIfNotFound(mq, subExpression, offset, maxNums);
+}
+void DefaultMQPullConsumer::pullBlockIfNotFound(const MQMessageQueue& mq,
+                                                const std::string& subExpression,
+                                                int64 offset,
+                                                int maxNums,
+                                                PullCallback* pPullCallback) {
+  impl->pullBlockIfNotFound(mq, subExpression, offset, maxNums, pPullCallback);
 }
 
-bool DefaultMQPullConsumer::producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest) {
-  return true;
+int64 DefaultMQPullConsumer::fetchConsumeOffset(const MQMessageQueue& mq, bool fromStore) {
+  return impl->fetchConsumeOffset(mq, fromStore);
 }
 
-Rebalance* DefaultMQPullConsumer::getRebalance() const {
-  return NULL;
-}
-// we should deal with name space before producer start.
-bool DefaultMQPullConsumer::dealWithNameSpace() {
-  string ns = getNameSpace();
-  if (ns.empty()) {
-    string nsAddr = getNamesrvAddr();
-    if (!NameSpaceUtil::checkNameSpaceExistInNameServer(nsAddr)) {
-      return true;
-    }
-    ns = NameSpaceUtil::getNameSpaceFromNsURL(nsAddr);
-    // reset namespace
-    setNameSpace(ns);
-  }
-  // reset group name
-  if (!NameSpaceUtil::hasNameSpace(getGroupName(), ns)) {
-    string fullGID = NameSpaceUtil::withNameSpace(getGroupName(), ns);
-    setGroupName(fullGID);
-  }
-  set<string> tmpTopics;
-  for (auto iter = m_registerTopics.begin(); iter != m_registerTopics.end(); iter++) {
-    string topic = *iter;
-    if (!NameSpaceUtil::hasNameSpace(topic, ns)) {
-      LOG_INFO("Update Subscribe Topic[%s] with NameSpace:%s", topic.c_str(), ns.c_str());
-      topic = NameSpaceUtil::withNameSpace(topic, ns);
-      // let other mode to known, the name space model opened.
-      m_useNameSpaceMode = true;
-    }
-    tmpTopics.insert(topic);
-  }
-  m_registerTopics.swap(tmpTopics);
-  return true;
+void DefaultMQPullConsumer::fetchMessageQueuesInBalance(const std::string& topic, std::vector<MQMessageQueue> mqs) {
+  impl->fetchMessageQueuesInBalance(topic, mqs);
 }
+void DefaultMQPullConsumer::persistConsumerOffset4PullConsumer(const MQMessageQueue& mq) {
+  // impl->persistConsumerOffsetByResetOffset(mq);
+}
+
 //<!************************************************************************
 }  // namespace rocketmq
diff --git a/src/consumer/DefaultMQPullConsumer.cpp b/src/consumer/DefaultMQPullConsumerImpl.cpp
similarity index 73%
copy from src/consumer/DefaultMQPullConsumer.cpp
copy to src/consumer/DefaultMQPullConsumerImpl.cpp
index 1f58e86..6408842 100644
--- a/src/consumer/DefaultMQPullConsumer.cpp
+++ b/src/consumer/DefaultMQPullConsumerImpl.cpp
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-#include "DefaultMQPullConsumer.h"
+#include "DefaultMQPullConsumerImpl.h"
 #include "AsyncArg.h"
 #include "CommunicationMode.h"
 #include "FilterAPI.h"
@@ -31,7 +31,7 @@
 
 namespace rocketmq {
 //<!***************************************************************************
-DefaultMQPullConsumer::DefaultMQPullConsumer(const string& groupname)
+DefaultMQPullConsumerImpl::DefaultMQPullConsumerImpl(const string& groupname)
     : m_pMessageQueueListener(NULL),
       m_pOffsetStore(NULL),
       m_pRebalance(NULL),
@@ -45,7 +45,7 @@ DefaultMQPullConsumer::DefaultMQPullConsumer(const string& groupname)
   setMessageModel(CLUSTERING);
 }
 
-DefaultMQPullConsumer::~DefaultMQPullConsumer() {
+DefaultMQPullConsumerImpl::~DefaultMQPullConsumerImpl() {
   m_pMessageQueueListener = NULL;
   deleteAndZero(m_pRebalance);
   deleteAndZero(m_pOffsetStore);
@@ -54,7 +54,7 @@ DefaultMQPullConsumer::~DefaultMQPullConsumer() {
 
 // MQConsumer
 //<!************************************************************************
-void DefaultMQPullConsumer::start() {
+void DefaultMQPullConsumerImpl::start() {
 #ifndef WIN32
   /* Ignore the SIGPIPE */
   struct sigaction sa;
@@ -67,8 +67,8 @@ void DefaultMQPullConsumer::start() {
   switch (m_serviceState) {
     case CREATE_JUST: {
       m_serviceState = START_FAILED;
-      MQClient::start();
-      LOG_INFO("DefaultMQPullConsumer:%s start", m_GroupName.c_str());
+      DefaultMQClient::start();
+      LOG_INFO("DefaultMQPullConsumerImpl:%s start", m_GroupName.c_str());
 
       //<!create rebalance;
       m_pRebalance = new RebalancePull(this, getFactory());
@@ -124,10 +124,10 @@ void DefaultMQPullConsumer::start() {
   }
 }
 
-void DefaultMQPullConsumer::shutdown() {
+void DefaultMQPullConsumerImpl::shutdown() {
   switch (m_serviceState) {
     case RUNNING: {
-      LOG_INFO("DefaultMQPullConsumer:%s shutdown", m_GroupName.c_str());
+      LOG_INFO("DefaultMQPullConsumerImpl:%s shutdown", m_GroupName.c_str());
       persistConsumerOffset();
       getFactory()->unregisterConsumer(this);
       getFactory()->shutdown();
@@ -142,11 +142,11 @@ void DefaultMQPullConsumer::shutdown() {
   }
 }
 
-bool DefaultMQPullConsumer::sendMessageBack(MQMessageExt& msg, int delayLevel, string& brokerName) {
+bool DefaultMQPullConsumerImpl::sendMessageBack(MQMessageExt& msg, int delayLevel, string& brokerName) {
   return true;
 }
 
-void DefaultMQPullConsumer::fetchSubscribeMessageQueues(const string& topic, vector<MQMessageQueue>& mqs) {
+void DefaultMQPullConsumerImpl::fetchSubscribeMessageQueues(const string& topic, vector<MQMessageQueue>& mqs) {
   mqs.clear();
   try {
     const string localTopic = NameSpaceUtil::withNameSpace(topic, getNameSpace());
@@ -156,50 +156,50 @@ void DefaultMQPullConsumer::fetchSubscribeMessageQueues(const string& topic, vec
   }
 }
 
-void DefaultMQPullConsumer::updateTopicSubscribeInfo(const string& topic, vector<MQMessageQueue>& info) {}
+void DefaultMQPullConsumerImpl::updateTopicSubscribeInfo(const string& topic, vector<MQMessageQueue>& info) {}
 
-void DefaultMQPullConsumer::registerMessageQueueListener(const string& topic, MQueueListener* pListener) {
+void DefaultMQPullConsumerImpl::registerMessageQueueListener(const string& topic, MQueueListener* pListener) {
   m_registerTopics.insert(topic);
   if (pListener) {
     m_pMessageQueueListener = pListener;
   }
 }
 
-PullResult DefaultMQPullConsumer::pull(const MQMessageQueue& mq,
-                                       const string& subExpression,
-                                       int64 offset,
-                                       int maxNums) {
+PullResult DefaultMQPullConsumerImpl::pull(const MQMessageQueue& mq,
+                                           const string& subExpression,
+                                           int64 offset,
+                                           int maxNums) {
   return pullSyncImpl(mq, subExpression, offset, maxNums, false);
 }
 
-void DefaultMQPullConsumer::pull(const MQMessageQueue& mq,
-                                 const string& subExpression,
-                                 int64 offset,
-                                 int maxNums,
-                                 PullCallback* pPullCallback) {
+void DefaultMQPullConsumerImpl::pull(const MQMessageQueue& mq,
+                                     const string& subExpression,
+                                     int64 offset,
+                                     int maxNums,
+                                     PullCallback* pPullCallback) {
   pullAsyncImpl(mq, subExpression, offset, maxNums, false, pPullCallback);
 }
 
-PullResult DefaultMQPullConsumer::pullBlockIfNotFound(const MQMessageQueue& mq,
-                                                      const string& subExpression,
-                                                      int64 offset,
-                                                      int maxNums) {
+PullResult DefaultMQPullConsumerImpl::pullBlockIfNotFound(const MQMessageQueue& mq,
+                                                          const string& subExpression,
+                                                          int64 offset,
+                                                          int maxNums) {
   return pullSyncImpl(mq, subExpression, offset, maxNums, true);
 }
 
-void DefaultMQPullConsumer::pullBlockIfNotFound(const MQMessageQueue& mq,
-                                                const string& subExpression,
-                                                int64 offset,
-                                                int maxNums,
-                                                PullCallback* pPullCallback) {
+void DefaultMQPullConsumerImpl::pullBlockIfNotFound(const MQMessageQueue& mq,
+                                                    const string& subExpression,
+                                                    int64 offset,
+                                                    int maxNums,
+                                                    PullCallback* pPullCallback) {
   pullAsyncImpl(mq, subExpression, offset, maxNums, true, pPullCallback);
 }
 
-PullResult DefaultMQPullConsumer::pullSyncImpl(const MQMessageQueue& mq,
-                                               const string& subExpression,
-                                               int64 offset,
-                                               int maxNums,
-                                               bool block) {
+PullResult DefaultMQPullConsumerImpl::pullSyncImpl(const MQMessageQueue& mq,
+                                                   const string& subExpression,
+                                                   int64 offset,
+                                                   int maxNums,
+                                                   bool block) {
   if (offset < 0)
     THROW_MQEXCEPTION(MQClientException, "offset < 0", -1);
 
@@ -240,12 +240,12 @@ PullResult DefaultMQPullConsumer::pullSyncImpl(const MQMessageQueue& mq,
   return PullResult(BROKER_TIMEOUT);
 }
 
-void DefaultMQPullConsumer::pullAsyncImpl(const MQMessageQueue& mq,
-                                          const string& subExpression,
-                                          int64 offset,
-                                          int maxNums,
-                                          bool block,
-                                          PullCallback* pPullCallback) {
+void DefaultMQPullConsumerImpl::pullAsyncImpl(const MQMessageQueue& mq,
+                                              const string& subExpression,
+                                              int64 offset,
+                                              int maxNums,
+                                              bool block,
+                                              PullCallback* pPullCallback) {
   if (offset < 0)
     THROW_MQEXCEPTION(MQClientException, "offset < 0", -1);
 
@@ -289,7 +289,7 @@ void DefaultMQPullConsumer::pullAsyncImpl(const MQMessageQueue& mq,
   }
 }
 
-void DefaultMQPullConsumer::subscriptionAutomatically(const string& topic) {
+void DefaultMQPullConsumerImpl::subscriptionAutomatically(const string& topic) {
   SubscriptionData* pSdata = m_pRebalance->getSubscriptionData(topic);
   if (pSdata == NULL) {
     unique_ptr<SubscriptionData> subscriptionData(FilterAPI::buildSubscriptionData(topic, SUB_ALL));
@@ -297,19 +297,19 @@ void DefaultMQPullConsumer::subscriptionAutomatically(const string& topic) {
   }
 }
 
-void DefaultMQPullConsumer::updateConsumeOffset(const MQMessageQueue& mq, int64 offset) {
+void DefaultMQPullConsumerImpl::updateConsumeOffset(const MQMessageQueue& mq, int64 offset) {
   m_pOffsetStore->updateOffset(mq, offset);
 }
 
-void DefaultMQPullConsumer::removeConsumeOffset(const MQMessageQueue& mq) {
+void DefaultMQPullConsumerImpl::removeConsumeOffset(const MQMessageQueue& mq) {
   m_pOffsetStore->removeOffset(mq);
 }
 
-int64 DefaultMQPullConsumer::fetchConsumeOffset(const MQMessageQueue& mq, bool fromStore) {
+int64 DefaultMQPullConsumerImpl::fetchConsumeOffset(const MQMessageQueue& mq, bool fromStore) {
   return m_pOffsetStore->readOffset(mq, fromStore ? READ_FROM_STORE : MEMORY_FIRST_THEN_STORE, getSessionCredentials());
 }
 
-void DefaultMQPullConsumer::persistConsumerOffset() {
+void DefaultMQPullConsumerImpl::persistConsumerOffset() {
   /*As do not execute rebalance for pullConsumer now, requestTable is always
   empty
   map<MQMessageQueue, PullRequest*> requestTable =
@@ -326,17 +326,17 @@ void DefaultMQPullConsumer::persistConsumerOffset() {
   m_pOffsetStore->persistAll(mqs);*/
 }
 
-void DefaultMQPullConsumer::persistConsumerOffsetByResetOffset() {}
+void DefaultMQPullConsumerImpl::persistConsumerOffsetByResetOffset() {}
 
-void DefaultMQPullConsumer::persistConsumerOffset4PullConsumer(const MQMessageQueue& mq) {
+void DefaultMQPullConsumerImpl::persistConsumerOffset4PullConsumer(const MQMessageQueue& mq) {
   if (isServiceStateOk()) {
     m_pOffsetStore->persist(mq, getSessionCredentials());
   }
 }
 
-void DefaultMQPullConsumer::fetchMessageQueuesInBalance(const string& topic, vector<MQMessageQueue> mqs) {}
+void DefaultMQPullConsumerImpl::fetchMessageQueuesInBalance(const string& topic, vector<MQMessageQueue> mqs) {}
 
-void DefaultMQPullConsumer::checkConfig() {
+void DefaultMQPullConsumerImpl::checkConfig() {
   string groupname = getGroupName();
   // check consumerGroup
   Validators::checkGroup(groupname);
@@ -351,9 +351,9 @@ void DefaultMQPullConsumer::checkConfig() {
   }
 }
 
-void DefaultMQPullConsumer::doRebalance() {}
+void DefaultMQPullConsumerImpl::doRebalance() {}
 
-void DefaultMQPullConsumer::copySubscription() {
+void DefaultMQPullConsumerImpl::copySubscription() {
   set<string>::iterator it = m_registerTopics.begin();
   for (; it != m_registerTopics.end(); ++it) {
     unique_ptr<SubscriptionData> subscriptionData(FilterAPI::buildSubscriptionData((*it), SUB_ALL));
@@ -361,15 +361,15 @@ void DefaultMQPullConsumer::copySubscription() {
   }
 }
 
-ConsumeType DefaultMQPullConsumer::getConsumeType() {
+ConsumeType DefaultMQPullConsumerImpl::getConsumeType() {
   return CONSUME_ACTIVELY;
 }
 
-ConsumeFromWhere DefaultMQPullConsumer::getConsumeFromWhere() {
+ConsumeFromWhere DefaultMQPullConsumerImpl::getConsumeFromWhere() {
   return CONSUME_FROM_LAST_OFFSET;
 }
 
-void DefaultMQPullConsumer::getSubscriptions(vector<SubscriptionData>& result) {
+void DefaultMQPullConsumerImpl::getSubscriptions(vector<SubscriptionData>& result) {
   set<string>::iterator it = m_registerTopics.begin();
   for (; it != m_registerTopics.end(); ++it) {
     SubscriptionData ms(*it, SUB_ALL);
@@ -377,15 +377,15 @@ void DefaultMQPullConsumer::getSubscriptions(vector<SubscriptionData>& result) {
   }
 }
 
-bool DefaultMQPullConsumer::producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest) {
+bool DefaultMQPullConsumerImpl::producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest) {
   return true;
 }
 
-Rebalance* DefaultMQPullConsumer::getRebalance() const {
+Rebalance* DefaultMQPullConsumerImpl::getRebalance() const {
   return NULL;
 }
 // we should deal with name space before producer start.
-bool DefaultMQPullConsumer::dealWithNameSpace() {
+bool DefaultMQPullConsumerImpl::dealWithNameSpace() {
   string ns = getNameSpace();
   if (ns.empty()) {
     string nsAddr = getNamesrvAddr();
diff --git a/include/DefaultMQPullConsumer.h b/src/consumer/DefaultMQPullConsumerImpl.h
similarity index 93%
copy from include/DefaultMQPullConsumer.h
copy to src/consumer/DefaultMQPullConsumerImpl.h
index 8e1612d..58d67e1 100644
--- a/include/DefaultMQPullConsumer.h
+++ b/src/consumer/DefaultMQPullConsumerImpl.h
@@ -1,148 +1,148 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-#ifndef __DEFAULTMQPULLCONSUMER_H__
-#define __DEFAULTMQPULLCONSUMER_H__
-
-#include <set>
-#include <string>
-#include "MQConsumer.h"
-#include "MQMessageQueue.h"
-#include "MQueueListener.h"
-#include "RocketMQClient.h"
-
-namespace rocketmq {
-class Rebalance;
-class SubscriptionData;
-class OffsetStore;
-class PullAPIWrapper;
-class ConsumerRunningInfo;
-//<!***************************************************************************
-class ROCKETMQCLIENT_API DefaultMQPullConsumer : public MQConsumer {
- public:
-  DefaultMQPullConsumer(const std::string& groupname);
-  virtual ~DefaultMQPullConsumer();
-
-  //<!begin mqadmin;
-  virtual void start();
-  virtual void shutdown();
-  //<!end mqadmin;
-
-  //<!begin MQConsumer
-  virtual bool sendMessageBack(MQMessageExt& msg, int delayLevel, std::string& brokerName);
-  virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs);
-  virtual void doRebalance();
-  virtual void persistConsumerOffset();
-  virtual void persistConsumerOffsetByResetOffset();
-  virtual void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info);
-  virtual ConsumeType getConsumeType();
-  virtual ConsumeFromWhere getConsumeFromWhere();
-  virtual void getSubscriptions(std::vector<SubscriptionData>&);
-  virtual void updateConsumeOffset(const MQMessageQueue& mq, int64 offset);
-  virtual void removeConsumeOffset(const MQMessageQueue& mq);
-  virtual bool producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest);
-  virtual Rebalance* getRebalance() const;
-  //<!end MQConsumer;
-
-  void registerMessageQueueListener(const std::string& topic, MQueueListener* pListener);
-  /**
-   * Pull message from specified queue, if no msg in queue, return directly
-   *
-   * @param mq
-   *            specify the pulled queue
-   * @param subExpression
-   *            set filter expression for pulled msg, broker will filter msg actively
-   *            Now only OR operation is supported, eg: "tag1 || tag2 || tag3"
-   *            if subExpression is setted to "null" or "*", all msg will be subscribed
-   * @param offset
-   *            specify the started pull offset
-   * @param maxNums
-   *            specify max msg num by per pull
-   * @return
-   *            PullResult
-   */
-  virtual PullResult pull(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums);
-  virtual void pull(const MQMessageQueue& mq,
-                    const std::string& subExpression,
-                    int64 offset,
-                    int maxNums,
-                    PullCallback* pPullCallback);
-
-  /**
-   * pull msg from specified queue, if no msg, broker will suspend the pull request 20s
-   *
-   * @param mq
-   *            specify the pulled queue
-   * @param subExpression
-   *            set filter expression for pulled msg, broker will filter msg actively
-   *            Now only OR operation is supported, eg: "tag1 || tag2 || tag3"
-   *            if subExpression is setted to "null" or "*", all msg will be subscribed
-   * @param offset
-   *            specify the started pull offset
-   * @param maxNums
-   *            specify max msg num by per pull
-   * @return
-   *            accroding to PullResult
-   */
-  PullResult pullBlockIfNotFound(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums);
-  void pullBlockIfNotFound(const MQMessageQueue& mq,
-                           const std::string& subExpression,
-                           int64 offset,
-                           int maxNums,
-                           PullCallback* pPullCallback);
-
-  virtual ConsumerRunningInfo* getConsumerRunningInfo() { return NULL; }
-
-  int64 fetchConsumeOffset(const MQMessageQueue& mq, bool fromStore);
-
-  void fetchMessageQueuesInBalance(const std::string& topic, std::vector<MQMessageQueue> mqs);
-
-  // temp persist consumer offset interface, only valid with
-  // RemoteBrokerOffsetStore, updateConsumeOffset should be called before.
-  void persistConsumerOffset4PullConsumer(const MQMessageQueue& mq);
-
- private:
-  void checkConfig();
-  void copySubscription();
-  bool dealWithNameSpace();
-
-  PullResult pullSyncImpl(const MQMessageQueue& mq,
-                          const std::string& subExpression,
-                          int64 offset,
-                          int maxNums,
-                          bool block);
-
-  void pullAsyncImpl(const MQMessageQueue& mq,
-                     const std::string& subExpression,
-                     int64 offset,
-                     int maxNums,
-                     bool block,
-                     PullCallback* pPullCallback);
-
-  void subscriptionAutomatically(const std::string& topic);
-
- private:
-  std::set<std::string> m_registerTopics;
-
-  MQueueListener* m_pMessageQueueListener;
-  OffsetStore* m_pOffsetStore;
-  Rebalance* m_pRebalance;
-  PullAPIWrapper* m_pPullAPIWrapper;
-};
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#ifndef __DEFAULTMQPULLCONSUMERIMPL_H__
+#define __DEFAULTMQPULLCONSUMERIMPL_H__
+
+#include <set>
+#include <string>
+#include "MQConsumer.h"
+#include "MQMessageQueue.h"
+#include "MQueueListener.h"
+#include "RocketMQClient.h"
+
+namespace rocketmq {
+class Rebalance;
+class SubscriptionData;
+class OffsetStore;
+class PullAPIWrapper;
+class ConsumerRunningInfo;
+//<!***************************************************************************
+class DefaultMQPullConsumerImpl : public MQConsumer {
+ public:
+  DefaultMQPullConsumerImpl(const std::string& groupname);
+  virtual ~DefaultMQPullConsumerImpl();
+
+  //<!begin mqadmin;
+  virtual void start();
+  virtual void shutdown();
+  //<!end mqadmin;
+
+  //<!begin MQConsumer
+  virtual bool sendMessageBack(MQMessageExt& msg, int delayLevel, std::string& brokerName);
+  virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs);
+  virtual void doRebalance();
+  virtual void persistConsumerOffset();
+  virtual void persistConsumerOffsetByResetOffset();
+  virtual void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info);
+  virtual ConsumeType getConsumeType();
+  virtual ConsumeFromWhere getConsumeFromWhere();
+  virtual void getSubscriptions(std::vector<SubscriptionData>&);
+  virtual void updateConsumeOffset(const MQMessageQueue& mq, int64 offset);
+  virtual void removeConsumeOffset(const MQMessageQueue& mq);
+  virtual bool producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest);
+  virtual Rebalance* getRebalance() const;
+  //<!end MQConsumer;
+
+  void registerMessageQueueListener(const std::string& topic, MQueueListener* pListener);
+  /**
+   * Pull message from specified queue, if no msg in queue, return directly
+   *
+   * @param mq
+   *            specify the pulled queue
+   * @param subExpression
+   *            set filter expression for pulled msg, broker will filter msg actively
+   *            Now only OR operation is supported, eg: "tag1 || tag2 || tag3"
+   *            if subExpression is setted to "null" or "*", all msg will be subscribed
+   * @param offset
+   *            specify the started pull offset
+   * @param maxNums
+   *            specify max msg num by per pull
+   * @return
+   *            PullResult
+   */
+  virtual PullResult pull(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums);
+  virtual void pull(const MQMessageQueue& mq,
+                    const std::string& subExpression,
+                    int64 offset,
+                    int maxNums,
+                    PullCallback* pPullCallback);
+
+  /**
+   * pull msg from specified queue, if no msg, broker will suspend the pull request 20s
+   *
+   * @param mq
+   *            specify the pulled queue
+   * @param subExpression
+   *            set filter expression for pulled msg, broker will filter msg actively
+   *            Now only OR operation is supported, eg: "tag1 || tag2 || tag3"
+   *            if subExpression is setted to "null" or "*", all msg will be subscribed
+   * @param offset
+   *            specify the started pull offset
+   * @param maxNums
+   *            specify max msg num by per pull
+   * @return
+   *            accroding to PullResult
+   */
+  PullResult pullBlockIfNotFound(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums);
+  void pullBlockIfNotFound(const MQMessageQueue& mq,
+                           const std::string& subExpression,
+                           int64 offset,
+                           int maxNums,
+                           PullCallback* pPullCallback);
+
+  virtual ConsumerRunningInfo* getConsumerRunningInfo() { return NULL; }
+
+  int64 fetchConsumeOffset(const MQMessageQueue& mq, bool fromStore);
+
+  void fetchMessageQueuesInBalance(const std::string& topic, std::vector<MQMessageQueue> mqs);
+
+  // temp persist consumer offset interface, only valid with
+  // RemoteBrokerOffsetStore, updateConsumeOffset should be called before.
+  void persistConsumerOffset4PullConsumer(const MQMessageQueue& mq);
+
+ private:
+  void checkConfig();
+  void copySubscription();
+  bool dealWithNameSpace();
+
+  PullResult pullSyncImpl(const MQMessageQueue& mq,
+                          const std::string& subExpression,
+                          int64 offset,
+                          int maxNums,
+                          bool block);
+
+  void pullAsyncImpl(const MQMessageQueue& mq,
+                     const std::string& subExpression,
+                     int64 offset,
+                     int maxNums,
+                     bool block,
+                     PullCallback* pPullCallback);
+
+  void subscriptionAutomatically(const std::string& topic);
+
+ private:
+  std::set<std::string> m_registerTopics;
+
+  MQueueListener* m_pMessageQueueListener;
+  OffsetStore* m_pOffsetStore;
+  Rebalance* m_pRebalance;
+  PullAPIWrapper* m_pPullAPIWrapper;
+};
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif
diff --git a/src/consumer/DefaultMQPushConsumer.cpp b/src/consumer/DefaultMQPushConsumer.cpp
index 9da0ca8..cede0c9 100644
--- a/src/consumer/DefaultMQPushConsumer.cpp
+++ b/src/consumer/DefaultMQPushConsumer.cpp
@@ -16,1027 +16,183 @@
  */
 
 #include "DefaultMQPushConsumer.h"
-#include "CommunicationMode.h"
-#include "ConsumeMsgService.h"
-#include "ConsumerRunningInfo.h"
-#include "FilterAPI.h"
-#include "Logging.h"
-#include "MQClientAPIImpl.h"
-#include "MQClientFactory.h"
-#include "NameSpaceUtil.h"
-#include "OffsetStore.h"
-#include "PullAPIWrapper.h"
-#include "PullSysFlag.h"
-#include "Rebalance.h"
-#include "UtilAll.h"
-#include "Validators.h"
-#include "task_queue.h"
+#include "DefaultMQPushConsumerImpl.h"
 
 namespace rocketmq {
 
-class AsyncPullCallback : public PullCallback {
- public:
-  AsyncPullCallback(DefaultMQPushConsumer* pushConsumer, boost::weak_ptr<PullRequest> request)
-      : m_callbackOwner(pushConsumer), m_pullRequest(request), m_bShutdown(false) {}
-
-  virtual ~AsyncPullCallback() { m_callbackOwner = NULL; }
-
-  virtual void onSuccess(MQMessageQueue& mq, PullResult& result, bool bProducePullRequest) {
-    boost::shared_ptr<PullRequest> pullRequest = m_pullRequest.lock();
-    if (!pullRequest) {
-      LOG_WARN("Pull request for[%s] has been released", mq.toString().c_str());
-      return;
-    }
-
-    if (m_bShutdown) {
-      LOG_INFO("pullrequest for:%s in shutdown, return", (pullRequest->m_messageQueue).toString().c_str());
-      return;
-    }
-    if (pullRequest->isDropped()) {
-      LOG_INFO("Pull request for queue[%s] has been set as dropped. Will NOT pull this queue any more",
-               pullRequest->m_messageQueue.toString().c_str());
-      return;
-    }
-    switch (result.pullStatus) {
-      case FOUND: {
-        if (pullRequest->isDropped()) {
-          LOG_INFO("[Dropped]Remove pullmsg event of mq:%s", (pullRequest->m_messageQueue).toString().c_str());
-          break;
-        }
-        pullRequest->setNextOffset(result.nextBeginOffset);
-        pullRequest->putMessage(result.msgFoundList);
-
-        m_callbackOwner->getConsumerMsgService()->submitConsumeRequest(pullRequest, result.msgFoundList);
-
-        if (bProducePullRequest) {
-          m_callbackOwner->producePullMsgTask(pullRequest);
-        } else {
-          LOG_INFO("[bProducePullRequest = false]Stop pullmsg event of mq:%s",
-                   (pullRequest->m_messageQueue).toString().c_str());
-        }
-
-        LOG_DEBUG("FOUND:%s with size:" SIZET_FMT ", nextBeginOffset:%lld",
-                  (pullRequest->m_messageQueue).toString().c_str(), result.msgFoundList.size(), result.nextBeginOffset);
-
-        break;
-      }
-      case NO_NEW_MSG: {
-        if (pullRequest->isDropped()) {
-          LOG_INFO("[Dropped]Remove pullmsg event of mq:%s", (pullRequest->m_messageQueue).toString().c_str());
-          break;
-        }
-        pullRequest->setNextOffset(result.nextBeginOffset);
-
-        vector<MQMessageExt> msgs;
-        pullRequest->getMessage(msgs);
-        if ((msgs.size() == 0) && (result.nextBeginOffset > 0)) {
-          m_callbackOwner->updateConsumeOffset(pullRequest->m_messageQueue, result.nextBeginOffset);
-        }
-        if (bProducePullRequest) {
-          m_callbackOwner->producePullMsgTask(pullRequest);
-        } else {
-          LOG_INFO("[bProducePullRequest = false]Stop pullmsg event of mq:%s",
-                   (pullRequest->m_messageQueue).toString().c_str());
-        }
-        LOG_DEBUG("NO_NEW_MSG:%s,nextBeginOffset:%lld", pullRequest->m_messageQueue.toString().c_str(),
-                  result.nextBeginOffset);
-        break;
-      }
-      case NO_MATCHED_MSG: {
-        if (pullRequest->isDropped()) {
-          LOG_INFO("[Dropped]Remove pullmsg event of mq:%s", (pullRequest->m_messageQueue).toString().c_str());
-          break;
-        }
-        pullRequest->setNextOffset(result.nextBeginOffset);
-
-        vector<MQMessageExt> msgs;
-        pullRequest->getMessage(msgs);
-        if ((msgs.size() == 0) && (result.nextBeginOffset > 0)) {
-          m_callbackOwner->updateConsumeOffset(pullRequest->m_messageQueue, result.nextBeginOffset);
-        }
-        if (bProducePullRequest) {
-          m_callbackOwner->producePullMsgTask(pullRequest);
-        } else {
-          LOG_INFO("[bProducePullRequest = false]Stop pullmsg event of mq:%s",
-                   (pullRequest->m_messageQueue).toString().c_str());
-        }
-        LOG_DEBUG("NO_MATCHED_MSG:%s,nextBeginOffset:%lld", pullRequest->m_messageQueue.toString().c_str(),
-                  result.nextBeginOffset);
-        break;
-      }
-      case OFFSET_ILLEGAL: {
-        if (pullRequest->isDropped()) {
-          LOG_INFO("[Dropped]Remove pullmsg event of mq:%s", (pullRequest->m_messageQueue).toString().c_str());
-          break;
-        }
-        pullRequest->setNextOffset(result.nextBeginOffset);
-        if (bProducePullRequest) {
-          m_callbackOwner->producePullMsgTask(pullRequest);
-        } else {
-          LOG_INFO("[bProducePullRequest = false]Stop pullmsg event of mq:%s",
-                   (pullRequest->m_messageQueue).toString().c_str());
-        }
-
-        LOG_DEBUG("OFFSET_ILLEGAL:%s,nextBeginOffset:%lld", pullRequest->m_messageQueue.toString().c_str(),
-                  result.nextBeginOffset);
-        break;
-      }
-      case BROKER_TIMEOUT: {
-        if (pullRequest->isDropped()) {
-          LOG_INFO("[Dropped]Remove pullmsg event of mq:%s", (pullRequest->m_messageQueue).toString().c_str());
-          break;
-        }
-        LOG_ERROR("impossible BROKER_TIMEOUT Occurs");
-        pullRequest->setNextOffset(result.nextBeginOffset);
-        if (bProducePullRequest) {
-          m_callbackOwner->producePullMsgTask(pullRequest);
-        } else {
-          LOG_INFO("[bProducePullRequest = false]Stop pullmsg event of mq:%s",
-                   (pullRequest->m_messageQueue).toString().c_str());
-        }
-        break;
-      }
-    }
-  }
-
-  virtual void onException(MQException& e) {
-    boost::shared_ptr<PullRequest> pullRequest = m_pullRequest.lock();
-    if (!pullRequest) {
-      LOG_WARN("Pull request has been released.");
-      return;
-    }
-    std::string queueName = pullRequest->m_messageQueue.toString();
-    if (m_bShutdown) {
-      LOG_INFO("pullrequest for:%s in shutdown, return", queueName.c_str());
-      return;
-    }
-    if (pullRequest->isDropped()) {
-      LOG_INFO("[Dropped]Remove pullmsg event of mq:%s", queueName.c_str());
-      return;
-    }
-    LOG_WARN("Pullrequest for:%s occurs exception, reproduce it after 1s.", queueName.c_str());
-    m_callbackOwner->producePullMsgTaskLater(pullRequest, 1000);
-  }
-
-  void setShutdownStatus() { m_bShutdown = true; }
-
-  const boost::weak_ptr<PullRequest>& getPullRequest() const { return m_pullRequest; }
-
-  void setPullRequest(boost::weak_ptr<PullRequest>& pullRequest) { m_pullRequest = pullRequest; }
-
- private:
-  DefaultMQPushConsumer* m_callbackOwner;
-  boost::weak_ptr<PullRequest> m_pullRequest;
-  bool m_bShutdown;
-};
-
-//<!***************************************************************************
-static boost::mutex m_asyncCallbackLock;
-
-DefaultMQPushConsumer::DefaultMQPushConsumer(const string& groupname)
-    : m_consumeFromWhere(CONSUME_FROM_LAST_OFFSET),
-      m_pOffsetStore(NULL),
-      m_pRebalance(NULL),
-      m_pPullAPIWrapper(NULL),
-      m_consumerService(NULL),
-      m_pMessageListener(NULL),
-      m_consumeMessageBatchMaxSize(1),
-      m_maxMsgCacheSize(1000),
-      m_pullmsgQueue(NULL) {
-  //<!set default group name;
-  string gname = groupname.empty() ? DEFAULT_CONSUMER_GROUP : groupname;
-  setGroupName(gname);
-  m_asyncPull = true;
-  m_useNameSpaceMode = false;
-  m_asyncPullTimeout = 30 * 1000;
-  setMessageModel(CLUSTERING);
-
-  m_startTime = UtilAll::currentTimeMillis();
-  m_consumeThreadCount = std::thread::hardware_concurrency();
-  m_pullMsgThreadPoolNum = std::thread::hardware_concurrency();
-  m_async_service_thread.reset(new boost::thread(boost::bind(&DefaultMQPushConsumer::boost_asio_work, this)));
-}
-
-void DefaultMQPushConsumer::boost_asio_work() {
-  LOG_INFO("DefaultMQPushConsumer::boost asio async service runing");
-  boost::asio::io_service::work work(m_async_ioService);  // avoid async io
-  // service stops after
-  // first timer timeout
-  // callback
-  m_async_ioService.run();
+DefaultMQPushConsumer::DefaultMQPushConsumer(const std::string& groupName) {
+  impl = new DefaultMQPushConsumerImpl(groupName);
 }
 
 DefaultMQPushConsumer::~DefaultMQPushConsumer() {
-  m_pMessageListener = NULL;
-  if (m_pullmsgQueue != NULL) {
-    deleteAndZero(m_pullmsgQueue);
-  }
-  if (m_pRebalance != NULL) {
-    deleteAndZero(m_pRebalance);
-  }
-  if (m_pOffsetStore != NULL) {
-    deleteAndZero(m_pOffsetStore);
-  }
-  if (m_pPullAPIWrapper != NULL) {
-    deleteAndZero(m_pPullAPIWrapper);
-  }
-  if (m_consumerService != NULL) {
-    deleteAndZero(m_consumerService);
-  }
-  PullMAP::iterator it = m_PullCallback.begin();
-  for (; it != m_PullCallback.end(); ++it) {
-    deleteAndZero(it->second);
-  }
-  m_PullCallback.clear();
-  m_subTopics.clear();
-}
-
-bool DefaultMQPushConsumer::sendMessageBack(MQMessageExt& msg, int delayLevel, string& brokerName) {
-  string brokerAddr;
-  if (!brokerName.empty())
-    brokerAddr = getFactory()->findBrokerAddressInPublish(brokerName);
-  else
-    brokerAddr = socketAddress2IPPort(msg.getStoreHost());
-  try {
-    getFactory()->getMQClientAPIImpl()->consumerSendMessageBack(brokerAddr, msg, getGroupName(), delayLevel,
-                                                                getMaxReconsumeTimes(), 3000, getSessionCredentials());
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    return false;
-  }
-  return true;
+  delete impl;
 }
-
-void DefaultMQPushConsumer::fetchSubscribeMessageQueues(const string& topic, vector<MQMessageQueue>& mqs) {
-  mqs.clear();
-  try {
-    getFactory()->fetchSubscribeMessageQueues(topic, mqs, getSessionCredentials());
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-  }
-}
-
-void DefaultMQPushConsumer::doRebalance() {
-  if (isServiceStateOk()) {
-    try {
-      m_pRebalance->doRebalance();
-    } catch (MQException& e) {
-      LOG_ERROR(e.what());
-    }
-  }
+void DefaultMQPushConsumer::start() {
+  impl->start();
 }
 
-void DefaultMQPushConsumer::persistConsumerOffset() {
-  if (isServiceStateOk()) {
-    m_pRebalance->persistConsumerOffset();
-  }
+void DefaultMQPushConsumer::shutdown() {
+  impl->shutdown();
 }
 
-void DefaultMQPushConsumer::persistConsumerOffsetByResetOffset() {
-  if (isServiceStateOk()) {
-    m_pRebalance->persistConsumerOffsetByResetOffset();
-  }
+ConsumeType DefaultMQPushConsumer::getConsumeType() {
+  return impl->getConsumeType();
 }
-
-void DefaultMQPushConsumer::start() {
-#ifndef WIN32
-  /* Ignore the SIGPIPE */
-  struct sigaction sa;
-  memset(&sa, 0, sizeof(struct sigaction));
-  sa.sa_handler = SIG_IGN;
-  sa.sa_flags = 0;
-  sigaction(SIGPIPE, &sa, 0);
-#endif
-  // deal with name space before start
-  dealWithNameSpace();
-  switch (m_serviceState) {
-    case CREATE_JUST: {
-      m_serviceState = START_FAILED;
-      MQClient::start();
-      LOG_INFO("DefaultMQPushConsumer:%s start", m_GroupName.c_str());
-
-      //<!data;
-      checkConfig();
-
-      //<!create rebalance;
-      m_pRebalance = new RebalancePush(this, getFactory());
-
-      string groupname = getGroupName();
-      m_pPullAPIWrapper = new PullAPIWrapper(getFactory(), groupname);
-
-      if (m_pMessageListener) {
-        if (m_pMessageListener->getMessageListenerType() == messageListenerOrderly) {
-          LOG_INFO("start orderly consume service:%s", getGroupName().c_str());
-          m_consumerService = new ConsumeMessageOrderlyService(this, m_consumeThreadCount, m_pMessageListener);
-        } else  // for backward compatible, defaultly and concurrently listeners
-                // are allocating ConsumeMessageConcurrentlyService
-        {
-          LOG_INFO("start concurrently consume service:%s", getGroupName().c_str());
-          m_consumerService = new ConsumeMessageConcurrentlyService(this, m_consumeThreadCount, m_pMessageListener);
-        }
-      }
-
-      m_pullmsgQueue = new TaskQueue(m_pullMsgThreadPoolNum);
-      m_pullmsgThread.reset(
-          new boost::thread(boost::bind(&DefaultMQPushConsumer::runPullMsgQueue, this, m_pullmsgQueue)));
-
-      copySubscription();
-
-      //<! registe;
-      bool registerOK = getFactory()->registerConsumer(this);
-      if (!registerOK) {
-        m_serviceState = CREATE_JUST;
-        THROW_MQEXCEPTION(
-            MQClientException,
-            "The cousumer group[" + getGroupName() + "] has been created before, specify another name please.", -1);
-      }
-
-      //<!msg model;
-      switch (getMessageModel()) {
-        case BROADCASTING:
-          m_pOffsetStore = new LocalFileOffsetStore(groupname, getFactory());
-          break;
-        case CLUSTERING:
-          m_pOffsetStore = new RemoteBrokerOffsetStore(groupname, getFactory());
-          break;
-      }
-      bool bStartFailed = false;
-      string errorMsg;
-      try {
-        m_pOffsetStore->load();
-      } catch (MQClientException& e) {
-        bStartFailed = true;
-        errorMsg = std::string(e.what());
-      }
-      m_consumerService->start();
-
-      getFactory()->start();
-
-      updateTopicSubscribeInfoWhenSubscriptionChanged();
-      getFactory()->sendHeartbeatToAllBroker();
-
-      m_serviceState = RUNNING;
-      if (bStartFailed) {
-        shutdown();
-        THROW_MQEXCEPTION(MQClientException, errorMsg, -1);
-      }
-      break;
-    }
-    case RUNNING:
-    case START_FAILED:
-    case SHUTDOWN_ALREADY:
-      break;
-    default:
-      break;
-  }
-
-  getFactory()->rebalanceImmediately();
+ConsumeFromWhere DefaultMQPushConsumer::getConsumeFromWhere() {
+  return impl->getConsumeFromWhere();
 }
-
-void DefaultMQPushConsumer::shutdown() {
-  switch (m_serviceState) {
-    case RUNNING: {
-      LOG_INFO("DefaultMQPushConsumer shutdown");
-      m_async_ioService.stop();
-      m_async_service_thread->interrupt();
-      m_async_service_thread->join();
-      m_pullmsgQueue->close();
-      m_pullmsgThread->interrupt();
-      m_pullmsgThread->join();
-      m_consumerService->shutdown();
-      persistConsumerOffset();
-      shutdownAsyncPullCallBack();  // delete aync pullMsg resources
-      getFactory()->unregisterConsumer(this);
-      getFactory()->shutdown();
-      m_serviceState = SHUTDOWN_ALREADY;
-      break;
-    }
-    case CREATE_JUST:
-    case SHUTDOWN_ALREADY:
-      break;
-    default:
-      break;
-  }
+void DefaultMQPushConsumer::setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
+  impl->setConsumeFromWhere(consumeFromWhere);
 }
 
 void DefaultMQPushConsumer::registerMessageListener(MQMessageListener* pMessageListener) {
-  if (NULL != pMessageListener) {
-    m_pMessageListener = pMessageListener;
-  }
+  impl->registerMessageListener(pMessageListener);
 }
-
 MessageListenerType DefaultMQPushConsumer::getMessageListenerType() {
-  if (NULL != m_pMessageListener) {
-    return m_pMessageListener->getMessageListenerType();
-  }
-  return messageListenerDefaultly;
+  return impl->getMessageListenerType();
 }
-
-ConsumeMsgService* DefaultMQPushConsumer::getConsumerMsgService() const {
-  return m_consumerService;
+void DefaultMQPushConsumer::subscribe(const std::string& topic, const std::string& subExpression) {
+  impl->subscribe(topic, subExpression);
 }
 
-OffsetStore* DefaultMQPushConsumer::getOffsetStore() const {
-  return m_pOffsetStore;
+void DefaultMQPushConsumer::setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize) {
+  impl->setConsumeMessageBatchMaxSize(consumeMessageBatchMaxSize);
 }
-
-Rebalance* DefaultMQPushConsumer::getRebalance() const {
-  return m_pRebalance;
+int DefaultMQPushConsumer::getConsumeMessageBatchMaxSize() const {
+  return impl->getConsumeMessageBatchMaxSize();
 }
 
-void DefaultMQPushConsumer::subscribe(const string& topic, const string& subExpression) {
-  m_subTopics[topic] = subExpression;
+/*
+  set consuming thread count, default value is cpu cores
+*/
+void DefaultMQPushConsumer::setConsumeThreadCount(int threadCount) {
+  impl->setConsumeThreadCount(threadCount);
 }
-
-void DefaultMQPushConsumer::checkConfig() {
-  string groupname = getGroupName();
-  // check consumerGroup
-  Validators::checkGroup(groupname);
-
-  // consumerGroup
-  if (!groupname.compare(DEFAULT_CONSUMER_GROUP)) {
-    THROW_MQEXCEPTION(MQClientException, "consumerGroup can not equal DEFAULT_CONSUMER", -1);
-  }
-
-  if (getMessageModel() != BROADCASTING && getMessageModel() != CLUSTERING) {
-    THROW_MQEXCEPTION(MQClientException, "messageModel is valid ", -1);
-  }
-
-  if (m_pMessageListener == NULL) {
-    THROW_MQEXCEPTION(MQClientException, "messageListener is null ", -1);
-  }
+int DefaultMQPushConsumer::getConsumeThreadCount() const {
+  return impl->getConsumeThreadCount();
 }
-
-void DefaultMQPushConsumer::copySubscription() {
-  map<string, string>::iterator it = m_subTopics.begin();
-  for (; it != m_subTopics.end(); ++it) {
-    LOG_INFO("buildSubscriptionData,:%s,%s", it->first.c_str(), it->second.c_str());
-    unique_ptr<SubscriptionData> pSData(FilterAPI::buildSubscriptionData(it->first, it->second));
-
-    m_pRebalance->setSubscriptionData(it->first, pSData.release());
-  }
-
-  switch (getMessageModel()) {
-    case BROADCASTING:
-      break;
-    case CLUSTERING: {
-      string retryTopic = UtilAll::getRetryTopic(getGroupName());
-
-      //<!this sub;
-      unique_ptr<SubscriptionData> pSData(FilterAPI::buildSubscriptionData(retryTopic, SUB_ALL));
-
-      m_pRebalance->setSubscriptionData(retryTopic, pSData.release());
-      break;
-    }
-    default:
-      break;
-  }
+void DefaultMQPushConsumer::setMaxReconsumeTimes(int maxReconsumeTimes) {
+  impl->setMaxReconsumeTimes(maxReconsumeTimes);
 }
-
-void DefaultMQPushConsumer::updateTopicSubscribeInfo(const string& topic, vector<MQMessageQueue>& info) {
-  m_pRebalance->setTopicSubscribeInfo(topic, info);
+int DefaultMQPushConsumer::getMaxReconsumeTimes() const {
+  return impl->getMaxReconsumeTimes();
 }
 
-void DefaultMQPushConsumer::updateTopicSubscribeInfoWhenSubscriptionChanged() {
-  map<string, SubscriptionData*>& subTable = m_pRebalance->getSubscriptionInner();
-  map<string, SubscriptionData*>::iterator it = subTable.begin();
-  for (; it != subTable.end(); ++it) {
-    bool btopic = getFactory()->updateTopicRouteInfoFromNameServer(it->first, getSessionCredentials());
-    if (btopic == false) {
-      LOG_WARN("The topic:[%s] not exist", it->first.c_str());
-    }
-  }
+/*
+  set pullMsg thread count, default value is cpu cores
+*/
+void DefaultMQPushConsumer::setPullMsgThreadPoolCount(int threadCount) {
+  impl->setPullMsgThreadPoolCount(threadCount);
 }
-
-ConsumeType DefaultMQPushConsumer::getConsumeType() {
-  return CONSUME_PASSIVELY;
+int DefaultMQPushConsumer::getPullMsgThreadPoolCount() const {
+  return impl->getPullMsgThreadPoolCount();
 }
 
-ConsumeFromWhere DefaultMQPushConsumer::getConsumeFromWhere() {
-  return m_consumeFromWhere;
+/*
+  set max cache msg size perQueue in memory if consumer could not consume msgs
+  immediately
+  default maxCacheMsgSize perQueue is 1000, set range is:1~65535
+*/
+void DefaultMQPushConsumer::setMaxCacheMsgSizePerQueue(int maxCacheSize) {
+  impl->setMaxCacheMsgSizePerQueue(maxCacheSize);
 }
-
-void DefaultMQPushConsumer::setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
-  m_consumeFromWhere = consumeFromWhere;
+int DefaultMQPushConsumer::getMaxCacheMsgSizePerQueue() const {
+  return impl->getMaxCacheMsgSizePerQueue();
 }
 
-void DefaultMQPushConsumer::getSubscriptions(vector<SubscriptionData>& result) {
-  map<string, SubscriptionData*>& subTable = m_pRebalance->getSubscriptionInner();
-  map<string, SubscriptionData*>::iterator it = subTable.begin();
-  for (; it != subTable.end(); ++it) {
-    result.push_back(*(it->second));
-  }
+MessageModel DefaultMQPushConsumer::getMessageModel() const {
+  return impl->getMessageModel();
 }
-
-void DefaultMQPushConsumer::updateConsumeOffset(const MQMessageQueue& mq, int64 offset) {
-  if (offset >= 0) {
-    m_pOffsetStore->updateOffset(mq, offset);
-  } else {
-    LOG_ERROR("updateConsumeOffset of mq:%s error", mq.toString().c_str());
-  }
+void DefaultMQPushConsumer::setMessageModel(MessageModel messageModel) {
+  impl->setMessageModel(messageModel);
 }
 
-void DefaultMQPushConsumer::removeConsumeOffset(const MQMessageQueue& mq) {
-  m_pOffsetStore->removeOffset(mq);
+const std::string& DefaultMQPushConsumer::getNamesrvAddr() const {
+  return impl->getNamesrvAddr();
 }
 
-void DefaultMQPushConsumer::static_triggerNextPullRequest(void* context,
-                                                          boost::asio::deadline_timer* t,
-                                                          boost::weak_ptr<PullRequest> pullRequest) {
-  if (pullRequest.expired()) {
-    LOG_WARN("Pull request has been released before.");
-    return;
-  }
-  DefaultMQPushConsumer* pDefaultMQPushConsumer = (DefaultMQPushConsumer*)context;
-  if (pDefaultMQPushConsumer) {
-    pDefaultMQPushConsumer->triggerNextPullRequest(t, pullRequest);
-  }
+void DefaultMQPushConsumer::setNamesrvAddr(const std::string& namesrvAddr) {
+  impl->setNamesrvAddr(namesrvAddr);
 }
 
-void DefaultMQPushConsumer::triggerNextPullRequest(boost::asio::deadline_timer* t,
-                                                   boost::weak_ptr<PullRequest> pullRequest) {
-  // delete first to avoild memleak
-  deleteAndZero(t);
-  boost::shared_ptr<PullRequest> request = pullRequest.lock();
-  if (!request) {
-    LOG_WARN("Pull request has been released before.");
-    return;
-  }
-  producePullMsgTask(request);
+const std::string& DefaultMQPushConsumer::getNamesrvDomain() const {
+  return impl->getNamesrvDomain();
 }
 
-bool DefaultMQPushConsumer::producePullMsgTaskLater(boost::weak_ptr<PullRequest> pullRequest, int millis) {
-  boost::shared_ptr<PullRequest> request = pullRequest.lock();
-  if (!request) {
-    LOG_INFO("Pull request is invalid. Maybe it is dropped before.");
-    return false;
-  }
-  if (request->isDropped()) {
-    LOG_INFO("[Dropped]Remove pullmsg event of mq:%s", request->m_messageQueue.toString().c_str());
-    return false;
-  }
-  if (m_pullmsgQueue->bTaskQueueStatusOK() && isServiceStateOk()) {
-    boost::asio::deadline_timer* t =
-        new boost::asio::deadline_timer(m_async_ioService, boost::posix_time::milliseconds(millis));
-    t->async_wait(boost::bind(&(DefaultMQPushConsumer::static_triggerNextPullRequest), this, t, request));
-    LOG_INFO("Produce Pull request [%s] Later and Sleep [%d]ms.", (request->m_messageQueue).toString().c_str(), millis);
-    return true;
-  } else {
-    LOG_WARN("Service or TaskQueue shutdown, produce PullRequest of mq:%s failed",
-             request->m_messageQueue.toString().c_str());
-    return false;
-  }
+void DefaultMQPushConsumer::setNamesrvDomain(const std::string& namesrvDomain) {
+  impl->setNamesrvDomain(namesrvDomain);
 }
-
-bool DefaultMQPushConsumer::producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest) {
-  boost::shared_ptr<PullRequest> request = pullRequest.lock();
-  if (!request) {
-    LOG_WARN("Pull request has been released.");
-    return false;
-  }
-  if (request->isDropped()) {
-    LOG_INFO("[Dropped]Remove pullmsg event of mq:%s", request->m_messageQueue.toString().c_str());
-    return false;
-  }
-  if (m_pullmsgQueue->bTaskQueueStatusOK() && isServiceStateOk()) {
-    if (m_asyncPull) {
-      m_pullmsgQueue->produce(TaskBinder::gen(&DefaultMQPushConsumer::pullMessageAsync, this, request));
-    } else {
-      m_pullmsgQueue->produce(TaskBinder::gen(&DefaultMQPushConsumer::pullMessage, this, request));
-    }
-  } else {
-    LOG_WARN("produce PullRequest of mq:%s failed", request->m_messageQueue.toString().c_str());
-    return false;
-  }
-  return true;
+void DefaultMQPushConsumer::setSessionCredentials(const std::string& accessKey,
+                                                  const std::string& secretKey,
+                                                  const std::string& accessChannel) {
+  impl->setSessionCredentials(accessKey, secretKey, accessChannel);
 }
 
-void DefaultMQPushConsumer::runPullMsgQueue(TaskQueue* pTaskQueue) {
-  pTaskQueue->run();
+const SessionCredentials& DefaultMQPushConsumer::getSessionCredentials() const {
+  return impl->getSessionCredentials();
 }
-
-void DefaultMQPushConsumer::pullMessage(boost::weak_ptr<PullRequest> pullRequest) {
-  boost::shared_ptr<PullRequest> request = pullRequest.lock();
-  if (!request) {
-    LOG_ERROR("Pull request is released, return");
-    return;
-  }
-  if (request->isDropped()) {
-    LOG_WARN("Pull request is set drop with mq:%s, return", (request->m_messageQueue).toString().c_str());
-    // request->removePullMsgEvent();
-    return;
-  }
-
-  MQMessageQueue& messageQueue = request->m_messageQueue;
-  if (m_consumerService->getConsumeMsgSerivceListenerType() == messageListenerOrderly) {
-    if (!request->isLocked() || request->isLockExpired()) {
-      if (!m_pRebalance->lock(messageQueue)) {
-        request->setLastPullTimestamp(UtilAll::currentTimeMillis());
-        producePullMsgTaskLater(request, 1000);
-        return;
-      }
-    }
-  }
-
-  if (request->getCacheMsgCount() > m_maxMsgCacheSize) {
-    LOG_INFO("Sync Pull request for %s has Cached with %d Messages and The Max size is %d, Sleep 1s.",
-             (request->m_messageQueue).toString().c_str(), request->getCacheMsgCount(), m_maxMsgCacheSize);
-    request->setLastPullTimestamp(UtilAll::currentTimeMillis());
-    // Retry 1s,
-    producePullMsgTaskLater(request, 1000);
-    return;
-  }
-
-  bool commitOffsetEnable = false;
-  int64 commitOffsetValue = 0;
-  if (CLUSTERING == getMessageModel()) {
-    commitOffsetValue = m_pOffsetStore->readOffset(messageQueue, READ_FROM_MEMORY, getSessionCredentials());
-    if (commitOffsetValue > 0) {
-      commitOffsetEnable = true;
-    }
-  }
-
-  string subExpression;
-  SubscriptionData* pSdata = m_pRebalance->getSubscriptionData(messageQueue.getTopic());
-  if (pSdata == NULL) {
-    LOG_INFO("Can not get SubscriptionData of Pull request for [%s], Sleep 1s.",
-             (request->m_messageQueue).toString().c_str());
-    producePullMsgTaskLater(request, 1000);
-    return;
-  }
-  subExpression = pSdata->getSubString();
-
-  int sysFlag = PullSysFlag::buildSysFlag(commitOffsetEnable,      // commitOffset
-                                          false,                   // suspend
-                                          !subExpression.empty(),  // subscription
-                                          false);                  // class filter
-  if (request->isDropped()) {
-    LOG_WARN("Pull request is set as dropped with mq:%s, return", (request->m_messageQueue).toString().c_str());
-    return;
-  }
-  try {
-    request->setLastPullTimestamp(UtilAll::currentTimeMillis());
-    unique_ptr<PullResult> result(m_pPullAPIWrapper->pullKernelImpl(messageQueue,              // 1
-                                                                    subExpression,             // 2
-                                                                    pSdata->getSubVersion(),   // 3
-                                                                    request->getNextOffset(),  // 4
-                                                                    32,                        // 5
-                                                                    sysFlag,                   // 6
-                                                                    commitOffsetValue,         // 7
-                                                                    1000 * 15,                 // 8
-                                                                    1000 * 30,                 // 9
-                                                                    ComMode_SYNC,              // 10
-                                                                    NULL, getSessionCredentials()));
-
-    PullResult pullResult = m_pPullAPIWrapper->processPullResult(messageQueue, result.get(), pSdata);
-    switch (pullResult.pullStatus) {
-      case FOUND: {
-        if (request->isDropped()) {
-          LOG_INFO("Get pull result but the queue has been marked as dropped. Queue: %s",
-                   messageQueue.toString().c_str());
-          break;
-        }
-        // and this request is dropped, and then received pulled msgs.
-        request->setNextOffset(pullResult.nextBeginOffset);
-        request->putMessage(pullResult.msgFoundList);
-
-        m_consumerService->submitConsumeRequest(request, pullResult.msgFoundList);
-        producePullMsgTask(request);
-
-        LOG_DEBUG("FOUND:%s with size:" SIZET_FMT ",nextBeginOffset:%lld", messageQueue.toString().c_str(),
-                  pullResult.msgFoundList.size(), pullResult.nextBeginOffset);
-
-        break;
-      }
-      case NO_NEW_MSG: {
-        if (request->isDropped()) {
-          LOG_INFO("Get pull result but the queue has been marked as dropped. Queue: %s",
-                   messageQueue.toString().c_str());
-          break;
-        }
-        request->setNextOffset(pullResult.nextBeginOffset);
-        vector<MQMessageExt> msgs;
-        request->getMessage(msgs);
-        if ((msgs.size() == 0) && (pullResult.nextBeginOffset > 0)) {
-          updateConsumeOffset(messageQueue, pullResult.nextBeginOffset);
-        }
-        producePullMsgTask(request);
-        LOG_DEBUG("NO_NEW_MSG:%s,nextBeginOffset:%lld", messageQueue.toString().c_str(), pullResult.nextBeginOffset);
-        break;
-      }
-      case NO_MATCHED_MSG: {
-        if (request->isDropped()) {
-          LOG_INFO("Get pull result but the queue has been marked as dropped. Queue: %s",
-                   messageQueue.toString().c_str());
-          break;
-        }
-        request->setNextOffset(pullResult.nextBeginOffset);
-        vector<MQMessageExt> msgs;
-        request->getMessage(msgs);
-        if ((msgs.size() == 0) && (pullResult.nextBeginOffset > 0)) {
-          updateConsumeOffset(messageQueue, pullResult.nextBeginOffset);
-        }
-        producePullMsgTask(request);
-
-        LOG_DEBUG("NO_MATCHED_MSG:%s,nextBeginOffset:%lld", messageQueue.toString().c_str(),
-                  pullResult.nextBeginOffset);
-        break;
-      }
-      case OFFSET_ILLEGAL: {
-        if (request->isDropped()) {
-          LOG_INFO("Get pull result but the queue has been marked as dropped. Queue: %s",
-                   messageQueue.toString().c_str());
-          break;
-        }
-        request->setNextOffset(pullResult.nextBeginOffset);
-        producePullMsgTask(request);
-
-        LOG_DEBUG("OFFSET_ILLEGAL:%s,nextBeginOffset:%lld", messageQueue.toString().c_str(),
-                  pullResult.nextBeginOffset);
-        break;
-      }
-      case BROKER_TIMEOUT: {  // as BROKER_TIMEOUT is defined by client, broker
-        // will not returns this status, so this case
-        // could not be entered.
-        LOG_ERROR("impossible BROKER_TIMEOUT Occurs");
-        request->setNextOffset(pullResult.nextBeginOffset);
-        producePullMsgTask(request);
-        break;
-      }
-    }
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    LOG_WARN("Pull %s occur exception, restart 1s  later.", messageQueue.toString().c_str());
-    producePullMsgTaskLater(request, 1000);
-  }
+const std::string& DefaultMQPushConsumer::getInstanceName() const {
+  return impl->getInstanceName();
 }
 
-AsyncPullCallback* DefaultMQPushConsumer::getAsyncPullCallBack(boost::weak_ptr<PullRequest> pullRequest,
-                                                               MQMessageQueue msgQueue) {
-  boost::shared_ptr<PullRequest> request = pullRequest.lock();
-  if (!request) {
-    return NULL;
-  }
-  boost::lock_guard<boost::mutex> lock(m_asyncCallbackLock);
-  if (m_asyncPull && request) {
-    PullMAP::iterator it = m_PullCallback.find(msgQueue);
-    if (it == m_PullCallback.end()) {
-      LOG_INFO("new pull callback for mq:%s", msgQueue.toString().c_str());
-      m_PullCallback[msgQueue] = new AsyncPullCallback(this, request);
-    }
-    AsyncPullCallback* asyncPullCallback = m_PullCallback[msgQueue];
-    if (asyncPullCallback && asyncPullCallback->getPullRequest().expired()) {
-      asyncPullCallback->setPullRequest(pullRequest);
-    }
-    return asyncPullCallback;
-  }
-
-  return NULL;
+void DefaultMQPushConsumer::setInstanceName(const std::string& instanceName) {
+  impl->setInstanceName(instanceName);
 }
 
-void DefaultMQPushConsumer::shutdownAsyncPullCallBack() {
-  boost::lock_guard<boost::mutex> lock(m_asyncCallbackLock);
-  if (m_asyncPull) {
-    PullMAP::iterator it = m_PullCallback.begin();
-    for (; it != m_PullCallback.end(); ++it) {
-      if (it->second) {
-        it->second->setShutdownStatus();
-      } else {
-        LOG_ERROR("could not find asyncPullCallback for:%s", it->first.toString().c_str());
-      }
-    }
-  }
+const std::string& DefaultMQPushConsumer::getNameSpace() const {
+  return impl->getNameSpace();
 }
 
-void DefaultMQPushConsumer::pullMessageAsync(boost::weak_ptr<PullRequest> pullRequest) {
-  boost::shared_ptr<PullRequest> request = pullRequest.lock();
-  if (!request) {
-    LOG_ERROR("Pull request is released, return");
-    return;
-  }
-  if (request->isDropped()) {
-    LOG_WARN("Pull request is set drop with mq:%s, return", (request->m_messageQueue).toString().c_str());
-    return;
-  }
-  MQMessageQueue& messageQueue = request->m_messageQueue;
-  if (m_consumerService->getConsumeMsgSerivceListenerType() == messageListenerOrderly) {
-    if (!request->isLocked() || request->isLockExpired()) {
-      if (!m_pRebalance->lock(messageQueue)) {
-        request->setLastPullTimestamp(UtilAll::currentTimeMillis());
-        // Retry later.
-        producePullMsgTaskLater(request, 1000);
-        return;
-      }
-    }
-  }
-
-  if (request->getCacheMsgCount() > m_maxMsgCacheSize) {
-    LOG_INFO("Pull request for [%s] has Cached with %d Messages and The Max size is %d, Sleep 3s.",
-             (request->m_messageQueue).toString().c_str(), request->getCacheMsgCount(), m_maxMsgCacheSize);
-    request->setLastPullTimestamp(UtilAll::currentTimeMillis());
-    // Retry 3s,
-    producePullMsgTaskLater(request, 3000);
-    return;
-  }
-
-  bool commitOffsetEnable = false;
-  int64 commitOffsetValue = 0;
-  if (CLUSTERING == getMessageModel()) {
-    commitOffsetValue = m_pOffsetStore->readOffset(messageQueue, READ_FROM_MEMORY, getSessionCredentials());
-    if (commitOffsetValue > 0) {
-      commitOffsetEnable = true;
-    }
-  }
-
-  string subExpression;
-  SubscriptionData* pSdata = (m_pRebalance->getSubscriptionData(messageQueue.getTopic()));
-  if (pSdata == NULL) {
-    LOG_INFO("Can not get SubscriptionData of Pull request for [%s], Sleep 1s.",
-             (request->m_messageQueue).toString().c_str());
-    // Subscribe data error, retry later.
-    producePullMsgTaskLater(request, 1000);
-    return;
-  }
-  subExpression = pSdata->getSubString();
-
-  int sysFlag = PullSysFlag::buildSysFlag(commitOffsetEnable,      // commitOffset
-                                          true,                    // suspend
-                                          !subExpression.empty(),  // subscription
-                                          false);                  // class filter
-
-  AsyncArg arg;
-  arg.mq = messageQueue;
-  arg.subData = *pSdata;
-  arg.pPullWrapper = m_pPullAPIWrapper;
-  if (request->isDropped()) {
-    LOG_WARN("Pull request is set as dropped with mq:%s, return", request->m_messageQueue.toString().c_str());
-    return;
-  }
-  try {
-    request->setLastPullTimestamp(UtilAll::currentTimeMillis());
-    AsyncPullCallback* pullCallback = getAsyncPullCallBack(request, messageQueue);
-    if (pullCallback == NULL) {
-      LOG_WARN("Can not get pull callback for:%s, Maybe this pull request has been released.",
-               request->m_messageQueue.toString().c_str());
-      return;
-    }
-    m_pPullAPIWrapper->pullKernelImpl(messageQueue,              // 1
-                                      subExpression,             // 2
-                                      pSdata->getSubVersion(),   // 3
-                                      request->getNextOffset(),  // 4
-                                      32,                        // 5
-                                      sysFlag,                   // 6
-                                      commitOffsetValue,         // 7
-                                      1000 * 15,                 // 8
-                                      m_asyncPullTimeout,        // 9
-                                      ComMode_ASYNC,             // 10
-                                      pullCallback,              // 11
-                                      getSessionCredentials(),   // 12
-                                      &arg);                     // 13
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    if (request->isDropped()) {
-      LOG_WARN("Pull request is set as dropped with mq:%s, return", (request->m_messageQueue).toString().c_str());
-      return;
-    }
-    LOG_INFO("Pull %s occur exception, restart 1s  later.", (request->m_messageQueue).toString().c_str());
-    producePullMsgTaskLater(request, 1000);
-  }
+void DefaultMQPushConsumer::setNameSpace(const std::string& nameSpace) {
+  impl->setNameSpace(nameSpace);
+}
+const std::string& DefaultMQPushConsumer::getGroupName() const {
+  return impl->getGroupName();
 }
 
-void DefaultMQPushConsumer::setAsyncPull(bool asyncFlag) {
-  if (asyncFlag) {
-    LOG_INFO("set pushConsumer:%s to async default pull mode", getGroupName().c_str());
-  } else {
-    LOG_INFO("set pushConsumer:%s to sync pull mode", getGroupName().c_str());
-  }
-  m_asyncPull = asyncFlag;
+void DefaultMQPushConsumer::setGroupName(const std::string& groupName) {
+  impl->setGroupName(groupName);
 }
 
-void DefaultMQPushConsumer::setConsumeThreadCount(int threadCount) {
-  if (threadCount > 0) {
-    m_consumeThreadCount = threadCount;
-  } else {
-    LOG_ERROR("setConsumeThreadCount with invalid value");
-  }
+void DefaultMQPushConsumer::setLogLevel(elogLevel inputLevel) {
+  impl->setLogLevel(inputLevel);
 }
 
-int DefaultMQPushConsumer::getConsumeThreadCount() const {
-  return m_consumeThreadCount;
+elogLevel DefaultMQPushConsumer::getLogLevel() {
+  return impl->getLogLevel();
 }
-void DefaultMQPushConsumer::setMaxReconsumeTimes(int maxReconsumeTimes) {
-  if (maxReconsumeTimes > 0) {
-    m_maxReconsumeTimes = maxReconsumeTimes;
-  } else {
-    LOG_ERROR("set maxReconsumeTimes with invalid value");
-  }
+void DefaultMQPushConsumer::setLogFileSizeAndNum(int fileNum, long perFileSize) {
+  impl->setLogFileSizeAndNum(fileNum, perFileSize);
 }
 
-int DefaultMQPushConsumer::getMaxReconsumeTimes() const {
-  if (m_maxReconsumeTimes >= 0) {
-    return m_maxReconsumeTimes;
-  }
-  // return 16 as default;
-  return 16;
+void DefaultMQPushConsumer::setUnitName(std::string unitName) {
+  impl->setUnitName(unitName);
 }
-
-void DefaultMQPushConsumer::setPullMsgThreadPoolCount(int threadCount) {
-  m_pullMsgThreadPoolNum = threadCount;
+const std::string& DefaultMQPushConsumer::getUnitName() const {
+  return impl->getUnitName();
 }
 
-int DefaultMQPushConsumer::getPullMsgThreadPoolCount() const {
-  return m_pullMsgThreadPoolNum;
+void DefaultMQPushConsumer::setTcpTransportPullThreadNum(int num) {
+  impl->setTcpTransportPullThreadNum(num);
 }
-
-int DefaultMQPushConsumer::getConsumeMessageBatchMaxSize() const {
-  return m_consumeMessageBatchMaxSize;
+const int DefaultMQPushConsumer::getTcpTransportPullThreadNum() const {
+  return impl->getTcpTransportPullThreadNum();
 }
 
-void DefaultMQPushConsumer::setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize) {
-  if (consumeMessageBatchMaxSize >= 1)
-    m_consumeMessageBatchMaxSize = consumeMessageBatchMaxSize;
+void DefaultMQPushConsumer::setTcpTransportConnectTimeout(uint64_t timeout) {
+  impl->setTcpTransportConnectTimeout(timeout);
 }
-
-void DefaultMQPushConsumer::setMaxCacheMsgSizePerQueue(int maxCacheSize) {
-  if (maxCacheSize > 0 && maxCacheSize < 65535) {
-    LOG_INFO("set maxCacheSize to:%d for consumer:%s", maxCacheSize, getGroupName().c_str());
-    m_maxMsgCacheSize = maxCacheSize;
-  }
+const uint64_t DefaultMQPushConsumer::getTcpTransportConnectTimeout() const {
+  return impl->getTcpTransportConnectTimeout();
 }
-
-int DefaultMQPushConsumer::getMaxCacheMsgSizePerQueue() const {
-  return m_maxMsgCacheSize;
+void DefaultMQPushConsumer::setTcpTransportTryLockTimeout(uint64_t timeout) {
+  impl->setTcpTransportTryLockTimeout(timeout);
 }
-
-ConsumerRunningInfo* DefaultMQPushConsumer::getConsumerRunningInfo() {
-  auto* info = new ConsumerRunningInfo();
-  if (m_consumerService->getConsumeMsgSerivceListenerType() == messageListenerOrderly) {
-    info->setProperty(ConsumerRunningInfo::PROP_CONSUME_ORDERLY, "true");
-  } else {
-    info->setProperty(ConsumerRunningInfo::PROP_CONSUME_ORDERLY, "false");
-  }
-  info->setProperty(ConsumerRunningInfo::PROP_THREADPOOL_CORE_SIZE, UtilAll::to_string(m_consumeThreadCount));
-  info->setProperty(ConsumerRunningInfo::PROP_CONSUMER_START_TIMESTAMP, UtilAll::to_string(m_startTime));
-
-  std::vector<SubscriptionData> result;
-  getSubscriptions(result);
-  info->setSubscriptionSet(result);
-
-  std::map<MQMessageQueue, boost::shared_ptr<PullRequest>> requestTable = m_pRebalance->getPullRequestTable();
-
-  for (const auto& it : requestTable) {
-    if (!it.second->isDropped()) {
-      MessageQueue queue((it.first).getTopic(), (it.first).getBrokerName(), (it.first).getQueueId());
-      ProcessQueueInfo processQueue;
-      processQueue.cachedMsgMinOffset = it.second->getCacheMinOffset();
-      processQueue.cachedMsgMaxOffset = it.second->getCacheMaxOffset();
-      processQueue.cachedMsgCount = it.second->getCacheMsgCount();
-      processQueue.setCommitOffset(
-          m_pOffsetStore->readOffset(it.first, MEMORY_FIRST_THEN_STORE, getSessionCredentials()));
-      processQueue.setDroped(it.second->isDropped());
-      processQueue.setLocked(it.second->isLocked());
-      processQueue.lastLockTimestamp = it.second->getLastLockTimestamp();
-      processQueue.lastPullTimestamp = it.second->getLastPullTimestamp();
-      processQueue.lastConsumeTimestamp = it.second->getLastConsumeTimestamp();
-      info->setMqTable(queue, processQueue);
-    }
-  }
-
-  return info;
+const uint64_t DefaultMQPushConsumer::getTcpTransportTryLockTimeout() const {
+  return impl->getTcpTransportTryLockTimeout();
 }
-// we should deal with name space before producer start.
-bool DefaultMQPushConsumer::dealWithNameSpace() {
-  string ns = getNameSpace();
-  if (ns.empty()) {
-    string nsAddr = getNamesrvAddr();
-    if (!NameSpaceUtil::checkNameSpaceExistInNameServer(nsAddr)) {
-      return true;
-    }
-    ns = NameSpaceUtil::getNameSpaceFromNsURL(nsAddr);
-    // reset namespace
-    setNameSpace(ns);
-  }
-  // reset group name
-  if (!NameSpaceUtil::hasNameSpace(getGroupName(), ns)) {
-    string fullGID = NameSpaceUtil::withNameSpace(getGroupName(), ns);
-    setGroupName(fullGID);
-  }
-  map<string, string> subTmp;
-  map<string, string>::iterator it = m_subTopics.begin();
-  for (; it != m_subTopics.end(); ++it) {
-    string topic = it->first;
-    string subs = it->second;
-    if (!NameSpaceUtil::hasNameSpace(topic, ns)) {
-      LOG_INFO("Update Subscribe[%s:%s] with NameSpace:%s", it->first.c_str(), it->second.c_str(), ns.c_str());
-      topic = NameSpaceUtil::withNameSpace(topic, ns);
-      // let other mode to known, the name space model opened.
-      m_useNameSpaceMode = true;
-    }
-    subTmp[topic] = subs;
-  }
-  m_subTopics.swap(subTmp);
-
-  return true;
+void DefaultMQPushConsumer::setAsyncPull(bool asyncFlag) {
+  impl->setAsyncPull(asyncFlag);
 }
 //<!************************************************************************
 }  // namespace rocketmq
diff --git a/src/consumer/DefaultMQPushConsumer.cpp b/src/consumer/DefaultMQPushConsumerImpl.cpp
similarity index 87%
copy from src/consumer/DefaultMQPushConsumer.cpp
copy to src/consumer/DefaultMQPushConsumerImpl.cpp
index 9da0ca8..54500bc 100644
--- a/src/consumer/DefaultMQPushConsumer.cpp
+++ b/src/consumer/DefaultMQPushConsumerImpl.cpp
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-#include "DefaultMQPushConsumer.h"
+#include "DefaultMQPushConsumerImpl.h"
 #include "CommunicationMode.h"
 #include "ConsumeMsgService.h"
 #include "ConsumerRunningInfo.h"
@@ -36,7 +36,7 @@ namespace rocketmq {
 
 class AsyncPullCallback : public PullCallback {
  public:
-  AsyncPullCallback(DefaultMQPushConsumer* pushConsumer, boost::weak_ptr<PullRequest> request)
+  AsyncPullCallback(DefaultMQPushConsumerImpl* pushConsumer, boost::weak_ptr<PullRequest> request)
       : m_callbackOwner(pushConsumer), m_pullRequest(request), m_bShutdown(false) {}
 
   virtual ~AsyncPullCallback() { m_callbackOwner = NULL; }
@@ -185,7 +185,7 @@ class AsyncPullCallback : public PullCallback {
   void setPullRequest(boost::weak_ptr<PullRequest>& pullRequest) { m_pullRequest = pullRequest; }
 
  private:
-  DefaultMQPushConsumer* m_callbackOwner;
+  DefaultMQPushConsumerImpl* m_callbackOwner;
   boost::weak_ptr<PullRequest> m_pullRequest;
   bool m_bShutdown;
 };
@@ -193,7 +193,7 @@ class AsyncPullCallback : public PullCallback {
 //<!***************************************************************************
 static boost::mutex m_asyncCallbackLock;
 
-DefaultMQPushConsumer::DefaultMQPushConsumer(const string& groupname)
+DefaultMQPushConsumerImpl::DefaultMQPushConsumerImpl(const string& groupname)
     : m_consumeFromWhere(CONSUME_FROM_LAST_OFFSET),
       m_pOffsetStore(NULL),
       m_pRebalance(NULL),
@@ -214,11 +214,11 @@ DefaultMQPushConsumer::DefaultMQPushConsumer(const string& groupname)
   m_startTime = UtilAll::currentTimeMillis();
   m_consumeThreadCount = std::thread::hardware_concurrency();
   m_pullMsgThreadPoolNum = std::thread::hardware_concurrency();
-  m_async_service_thread.reset(new boost::thread(boost::bind(&DefaultMQPushConsumer::boost_asio_work, this)));
+  m_async_service_thread.reset(new boost::thread(boost::bind(&DefaultMQPushConsumerImpl::boost_asio_work, this)));
 }
 
-void DefaultMQPushConsumer::boost_asio_work() {
-  LOG_INFO("DefaultMQPushConsumer::boost asio async service runing");
+void DefaultMQPushConsumerImpl::boost_asio_work() {
+  LOG_INFO("DefaultMQPushConsumerImpl::boost asio async service runing");
   boost::asio::io_service::work work(m_async_ioService);  // avoid async io
   // service stops after
   // first timer timeout
@@ -226,7 +226,7 @@ void DefaultMQPushConsumer::boost_asio_work() {
   m_async_ioService.run();
 }
 
-DefaultMQPushConsumer::~DefaultMQPushConsumer() {
+DefaultMQPushConsumerImpl::~DefaultMQPushConsumerImpl() {
   m_pMessageListener = NULL;
   if (m_pullmsgQueue != NULL) {
     deleteAndZero(m_pullmsgQueue);
@@ -251,7 +251,7 @@ DefaultMQPushConsumer::~DefaultMQPushConsumer() {
   m_subTopics.clear();
 }
 
-bool DefaultMQPushConsumer::sendMessageBack(MQMessageExt& msg, int delayLevel, string& brokerName) {
+bool DefaultMQPushConsumerImpl::sendMessageBack(MQMessageExt& msg, int delayLevel, string& brokerName) {
   string brokerAddr;
   if (!brokerName.empty())
     brokerAddr = getFactory()->findBrokerAddressInPublish(brokerName);
@@ -267,7 +267,7 @@ bool DefaultMQPushConsumer::sendMessageBack(MQMessageExt& msg, int delayLevel, s
   return true;
 }
 
-void DefaultMQPushConsumer::fetchSubscribeMessageQueues(const string& topic, vector<MQMessageQueue>& mqs) {
+void DefaultMQPushConsumerImpl::fetchSubscribeMessageQueues(const string& topic, vector<MQMessageQueue>& mqs) {
   mqs.clear();
   try {
     getFactory()->fetchSubscribeMessageQueues(topic, mqs, getSessionCredentials());
@@ -276,7 +276,7 @@ void DefaultMQPushConsumer::fetchSubscribeMessageQueues(const string& topic, vec
   }
 }
 
-void DefaultMQPushConsumer::doRebalance() {
+void DefaultMQPushConsumerImpl::doRebalance() {
   if (isServiceStateOk()) {
     try {
       m_pRebalance->doRebalance();
@@ -286,19 +286,19 @@ void DefaultMQPushConsumer::doRebalance() {
   }
 }
 
-void DefaultMQPushConsumer::persistConsumerOffset() {
+void DefaultMQPushConsumerImpl::persistConsumerOffset() {
   if (isServiceStateOk()) {
     m_pRebalance->persistConsumerOffset();
   }
 }
 
-void DefaultMQPushConsumer::persistConsumerOffsetByResetOffset() {
+void DefaultMQPushConsumerImpl::persistConsumerOffsetByResetOffset() {
   if (isServiceStateOk()) {
     m_pRebalance->persistConsumerOffsetByResetOffset();
   }
 }
 
-void DefaultMQPushConsumer::start() {
+void DefaultMQPushConsumerImpl::start() {
 #ifndef WIN32
   /* Ignore the SIGPIPE */
   struct sigaction sa;
@@ -312,8 +312,8 @@ void DefaultMQPushConsumer::start() {
   switch (m_serviceState) {
     case CREATE_JUST: {
       m_serviceState = START_FAILED;
-      MQClient::start();
-      LOG_INFO("DefaultMQPushConsumer:%s start", m_GroupName.c_str());
+      DefaultMQClient::start();
+      LOG_INFO("DefaultMQPushConsumerImpl:%s start", m_GroupName.c_str());
 
       //<!data;
       checkConfig();
@@ -338,7 +338,7 @@ void DefaultMQPushConsumer::start() {
 
       m_pullmsgQueue = new TaskQueue(m_pullMsgThreadPoolNum);
       m_pullmsgThread.reset(
-          new boost::thread(boost::bind(&DefaultMQPushConsumer::runPullMsgQueue, this, m_pullmsgQueue)));
+          new boost::thread(boost::bind(&DefaultMQPushConsumerImpl::runPullMsgQueue, this, m_pullmsgQueue)));
 
       copySubscription();
 
@@ -393,10 +393,10 @@ void DefaultMQPushConsumer::start() {
   getFactory()->rebalanceImmediately();
 }
 
-void DefaultMQPushConsumer::shutdown() {
+void DefaultMQPushConsumerImpl::shutdown() {
   switch (m_serviceState) {
     case RUNNING: {
-      LOG_INFO("DefaultMQPushConsumer shutdown");
+      LOG_INFO("DefaultMQPushConsumerImpl shutdown");
       m_async_ioService.stop();
       m_async_service_thread->interrupt();
       m_async_service_thread->join();
@@ -419,36 +419,36 @@ void DefaultMQPushConsumer::shutdown() {
   }
 }
 
-void DefaultMQPushConsumer::registerMessageListener(MQMessageListener* pMessageListener) {
+void DefaultMQPushConsumerImpl::registerMessageListener(MQMessageListener* pMessageListener) {
   if (NULL != pMessageListener) {
     m_pMessageListener = pMessageListener;
   }
 }
 
-MessageListenerType DefaultMQPushConsumer::getMessageListenerType() {
+MessageListenerType DefaultMQPushConsumerImpl::getMessageListenerType() {
   if (NULL != m_pMessageListener) {
     return m_pMessageListener->getMessageListenerType();
   }
   return messageListenerDefaultly;
 }
 
-ConsumeMsgService* DefaultMQPushConsumer::getConsumerMsgService() const {
+ConsumeMsgService* DefaultMQPushConsumerImpl::getConsumerMsgService() const {
   return m_consumerService;
 }
 
-OffsetStore* DefaultMQPushConsumer::getOffsetStore() const {
+OffsetStore* DefaultMQPushConsumerImpl::getOffsetStore() const {
   return m_pOffsetStore;
 }
 
-Rebalance* DefaultMQPushConsumer::getRebalance() const {
+Rebalance* DefaultMQPushConsumerImpl::getRebalance() const {
   return m_pRebalance;
 }
 
-void DefaultMQPushConsumer::subscribe(const string& topic, const string& subExpression) {
+void DefaultMQPushConsumerImpl::subscribe(const string& topic, const string& subExpression) {
   m_subTopics[topic] = subExpression;
 }
 
-void DefaultMQPushConsumer::checkConfig() {
+void DefaultMQPushConsumerImpl::checkConfig() {
   string groupname = getGroupName();
   // check consumerGroup
   Validators::checkGroup(groupname);
@@ -467,7 +467,7 @@ void DefaultMQPushConsumer::checkConfig() {
   }
 }
 
-void DefaultMQPushConsumer::copySubscription() {
+void DefaultMQPushConsumerImpl::copySubscription() {
   map<string, string>::iterator it = m_subTopics.begin();
   for (; it != m_subTopics.end(); ++it) {
     LOG_INFO("buildSubscriptionData,:%s,%s", it->first.c_str(), it->second.c_str());
@@ -493,11 +493,11 @@ void DefaultMQPushConsumer::copySubscription() {
   }
 }
 
-void DefaultMQPushConsumer::updateTopicSubscribeInfo(const string& topic, vector<MQMessageQueue>& info) {
+void DefaultMQPushConsumerImpl::updateTopicSubscribeInfo(const string& topic, vector<MQMessageQueue>& info) {
   m_pRebalance->setTopicSubscribeInfo(topic, info);
 }
 
-void DefaultMQPushConsumer::updateTopicSubscribeInfoWhenSubscriptionChanged() {
+void DefaultMQPushConsumerImpl::updateTopicSubscribeInfoWhenSubscriptionChanged() {
   map<string, SubscriptionData*>& subTable = m_pRebalance->getSubscriptionInner();
   map<string, SubscriptionData*>::iterator it = subTable.begin();
   for (; it != subTable.end(); ++it) {
@@ -508,19 +508,19 @@ void DefaultMQPushConsumer::updateTopicSubscribeInfoWhenSubscriptionChanged() {
   }
 }
 
-ConsumeType DefaultMQPushConsumer::getConsumeType() {
+ConsumeType DefaultMQPushConsumerImpl::getConsumeType() {
   return CONSUME_PASSIVELY;
 }
 
-ConsumeFromWhere DefaultMQPushConsumer::getConsumeFromWhere() {
+ConsumeFromWhere DefaultMQPushConsumerImpl::getConsumeFromWhere() {
   return m_consumeFromWhere;
 }
 
-void DefaultMQPushConsumer::setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
+void DefaultMQPushConsumerImpl::setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
   m_consumeFromWhere = consumeFromWhere;
 }
 
-void DefaultMQPushConsumer::getSubscriptions(vector<SubscriptionData>& result) {
+void DefaultMQPushConsumerImpl::getSubscriptions(vector<SubscriptionData>& result) {
   map<string, SubscriptionData*>& subTable = m_pRebalance->getSubscriptionInner();
   map<string, SubscriptionData*>::iterator it = subTable.begin();
   for (; it != subTable.end(); ++it) {
@@ -528,7 +528,7 @@ void DefaultMQPushConsumer::getSubscriptions(vector<SubscriptionData>& result) {
   }
 }
 
-void DefaultMQPushConsumer::updateConsumeOffset(const MQMessageQueue& mq, int64 offset) {
+void DefaultMQPushConsumerImpl::updateConsumeOffset(const MQMessageQueue& mq, int64 offset) {
   if (offset >= 0) {
     m_pOffsetStore->updateOffset(mq, offset);
   } else {
@@ -536,25 +536,25 @@ void DefaultMQPushConsumer::updateConsumeOffset(const MQMessageQueue& mq, int64
   }
 }
 
-void DefaultMQPushConsumer::removeConsumeOffset(const MQMessageQueue& mq) {
+void DefaultMQPushConsumerImpl::removeConsumeOffset(const MQMessageQueue& mq) {
   m_pOffsetStore->removeOffset(mq);
 }
 
-void DefaultMQPushConsumer::static_triggerNextPullRequest(void* context,
-                                                          boost::asio::deadline_timer* t,
-                                                          boost::weak_ptr<PullRequest> pullRequest) {
+void DefaultMQPushConsumerImpl::static_triggerNextPullRequest(void* context,
+                                                              boost::asio::deadline_timer* t,
+                                                              boost::weak_ptr<PullRequest> pullRequest) {
   if (pullRequest.expired()) {
     LOG_WARN("Pull request has been released before.");
     return;
   }
-  DefaultMQPushConsumer* pDefaultMQPushConsumer = (DefaultMQPushConsumer*)context;
-  if (pDefaultMQPushConsumer) {
-    pDefaultMQPushConsumer->triggerNextPullRequest(t, pullRequest);
+  DefaultMQPushConsumerImpl* pDefaultMQPushConsumerImpl = (DefaultMQPushConsumerImpl*)context;
+  if (pDefaultMQPushConsumerImpl) {
+    pDefaultMQPushConsumerImpl->triggerNextPullRequest(t, pullRequest);
   }
 }
 
-void DefaultMQPushConsumer::triggerNextPullRequest(boost::asio::deadline_timer* t,
-                                                   boost::weak_ptr<PullRequest> pullRequest) {
+void DefaultMQPushConsumerImpl::triggerNextPullRequest(boost::asio::deadline_timer* t,
+                                                       boost::weak_ptr<PullRequest> pullRequest) {
   // delete first to avoild memleak
   deleteAndZero(t);
   boost::shared_ptr<PullRequest> request = pullRequest.lock();
@@ -565,7 +565,7 @@ void DefaultMQPushConsumer::triggerNextPullRequest(boost::asio::deadline_timer*
   producePullMsgTask(request);
 }
 
-bool DefaultMQPushConsumer::producePullMsgTaskLater(boost::weak_ptr<PullRequest> pullRequest, int millis) {
+bool DefaultMQPushConsumerImpl::producePullMsgTaskLater(boost::weak_ptr<PullRequest> pullRequest, int millis) {
   boost::shared_ptr<PullRequest> request = pullRequest.lock();
   if (!request) {
     LOG_INFO("Pull request is invalid. Maybe it is dropped before.");
@@ -578,7 +578,7 @@ bool DefaultMQPushConsumer::producePullMsgTaskLater(boost::weak_ptr<PullRequest>
   if (m_pullmsgQueue->bTaskQueueStatusOK() && isServiceStateOk()) {
     boost::asio::deadline_timer* t =
         new boost::asio::deadline_timer(m_async_ioService, boost::posix_time::milliseconds(millis));
-    t->async_wait(boost::bind(&(DefaultMQPushConsumer::static_triggerNextPullRequest), this, t, request));
+    t->async_wait(boost::bind(&(DefaultMQPushConsumerImpl::static_triggerNextPullRequest), this, t, request));
     LOG_INFO("Produce Pull request [%s] Later and Sleep [%d]ms.", (request->m_messageQueue).toString().c_str(), millis);
     return true;
   } else {
@@ -588,7 +588,7 @@ bool DefaultMQPushConsumer::producePullMsgTaskLater(boost::weak_ptr<PullRequest>
   }
 }
 
-bool DefaultMQPushConsumer::producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest) {
+bool DefaultMQPushConsumerImpl::producePullMsgTask(boost::weak_ptr<PullRequest> pullRequest) {
   boost::shared_ptr<PullRequest> request = pullRequest.lock();
   if (!request) {
     LOG_WARN("Pull request has been released.");
@@ -600,9 +600,9 @@ bool DefaultMQPushConsumer::producePullMsgTask(boost::weak_ptr<PullRequest> pull
   }
   if (m_pullmsgQueue->bTaskQueueStatusOK() && isServiceStateOk()) {
     if (m_asyncPull) {
-      m_pullmsgQueue->produce(TaskBinder::gen(&DefaultMQPushConsumer::pullMessageAsync, this, request));
+      m_pullmsgQueue->produce(TaskBinder::gen(&DefaultMQPushConsumerImpl::pullMessageAsync, this, request));
     } else {
-      m_pullmsgQueue->produce(TaskBinder::gen(&DefaultMQPushConsumer::pullMessage, this, request));
+      m_pullmsgQueue->produce(TaskBinder::gen(&DefaultMQPushConsumerImpl::pullMessage, this, request));
     }
   } else {
     LOG_WARN("produce PullRequest of mq:%s failed", request->m_messageQueue.toString().c_str());
@@ -611,11 +611,11 @@ bool DefaultMQPushConsumer::producePullMsgTask(boost::weak_ptr<PullRequest> pull
   return true;
 }
 
-void DefaultMQPushConsumer::runPullMsgQueue(TaskQueue* pTaskQueue) {
+void DefaultMQPushConsumerImpl::runPullMsgQueue(TaskQueue* pTaskQueue) {
   pTaskQueue->run();
 }
 
-void DefaultMQPushConsumer::pullMessage(boost::weak_ptr<PullRequest> pullRequest) {
+void DefaultMQPushConsumerImpl::pullMessage(boost::weak_ptr<PullRequest> pullRequest) {
   boost::shared_ptr<PullRequest> request = pullRequest.lock();
   if (!request) {
     LOG_ERROR("Pull request is released, return");
@@ -771,8 +771,8 @@ void DefaultMQPushConsumer::pullMessage(boost::weak_ptr<PullRequest> pullRequest
   }
 }
 
-AsyncPullCallback* DefaultMQPushConsumer::getAsyncPullCallBack(boost::weak_ptr<PullRequest> pullRequest,
-                                                               MQMessageQueue msgQueue) {
+AsyncPullCallback* DefaultMQPushConsumerImpl::getAsyncPullCallBack(boost::weak_ptr<PullRequest> pullRequest,
+                                                                   MQMessageQueue msgQueue) {
   boost::shared_ptr<PullRequest> request = pullRequest.lock();
   if (!request) {
     return NULL;
@@ -794,7 +794,7 @@ AsyncPullCallback* DefaultMQPushConsumer::getAsyncPullCallBack(boost::weak_ptr<P
   return NULL;
 }
 
-void DefaultMQPushConsumer::shutdownAsyncPullCallBack() {
+void DefaultMQPushConsumerImpl::shutdownAsyncPullCallBack() {
   boost::lock_guard<boost::mutex> lock(m_asyncCallbackLock);
   if (m_asyncPull) {
     PullMAP::iterator it = m_PullCallback.begin();
@@ -808,7 +808,7 @@ void DefaultMQPushConsumer::shutdownAsyncPullCallBack() {
   }
 }
 
-void DefaultMQPushConsumer::pullMessageAsync(boost::weak_ptr<PullRequest> pullRequest) {
+void DefaultMQPushConsumerImpl::pullMessageAsync(boost::weak_ptr<PullRequest> pullRequest) {
   boost::shared_ptr<PullRequest> request = pullRequest.lock();
   if (!request) {
     LOG_ERROR("Pull request is released, return");
@@ -904,7 +904,7 @@ void DefaultMQPushConsumer::pullMessageAsync(boost::weak_ptr<PullRequest> pullRe
   }
 }
 
-void DefaultMQPushConsumer::setAsyncPull(bool asyncFlag) {
+void DefaultMQPushConsumerImpl::setAsyncPull(bool asyncFlag) {
   if (asyncFlag) {
     LOG_INFO("set pushConsumer:%s to async default pull mode", getGroupName().c_str());
   } else {
@@ -913,7 +913,7 @@ void DefaultMQPushConsumer::setAsyncPull(bool asyncFlag) {
   m_asyncPull = asyncFlag;
 }
 
-void DefaultMQPushConsumer::setConsumeThreadCount(int threadCount) {
+void DefaultMQPushConsumerImpl::setConsumeThreadCount(int threadCount) {
   if (threadCount > 0) {
     m_consumeThreadCount = threadCount;
   } else {
@@ -921,10 +921,10 @@ void DefaultMQPushConsumer::setConsumeThreadCount(int threadCount) {
   }
 }
 
-int DefaultMQPushConsumer::getConsumeThreadCount() const {
+int DefaultMQPushConsumerImpl::getConsumeThreadCount() const {
   return m_consumeThreadCount;
 }
-void DefaultMQPushConsumer::setMaxReconsumeTimes(int maxReconsumeTimes) {
+void DefaultMQPushConsumerImpl::setMaxReconsumeTimes(int maxReconsumeTimes) {
   if (maxReconsumeTimes > 0) {
     m_maxReconsumeTimes = maxReconsumeTimes;
   } else {
@@ -932,7 +932,7 @@ void DefaultMQPushConsumer::setMaxReconsumeTimes(int maxReconsumeTimes) {
   }
 }
 
-int DefaultMQPushConsumer::getMaxReconsumeTimes() const {
+int DefaultMQPushConsumerImpl::getMaxReconsumeTimes() const {
   if (m_maxReconsumeTimes >= 0) {
     return m_maxReconsumeTimes;
   }
@@ -940,35 +940,35 @@ int DefaultMQPushConsumer::getMaxReconsumeTimes() const {
   return 16;
 }
 
-void DefaultMQPushConsumer::setPullMsgThreadPoolCount(int threadCount) {
+void DefaultMQPushConsumerImpl::setPullMsgThreadPoolCount(int threadCount) {
   m_pullMsgThreadPoolNum = threadCount;
 }
 
-int DefaultMQPushConsumer::getPullMsgThreadPoolCount() const {
+int DefaultMQPushConsumerImpl::getPullMsgThreadPoolCount() const {
   return m_pullMsgThreadPoolNum;
 }
 
-int DefaultMQPushConsumer::getConsumeMessageBatchMaxSize() const {
+int DefaultMQPushConsumerImpl::getConsumeMessageBatchMaxSize() const {
   return m_consumeMessageBatchMaxSize;
 }
 
-void DefaultMQPushConsumer::setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize) {
+void DefaultMQPushConsumerImpl::setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize) {
   if (consumeMessageBatchMaxSize >= 1)
     m_consumeMessageBatchMaxSize = consumeMessageBatchMaxSize;
 }
 
-void DefaultMQPushConsumer::setMaxCacheMsgSizePerQueue(int maxCacheSize) {
+void DefaultMQPushConsumerImpl::setMaxCacheMsgSizePerQueue(int maxCacheSize) {
   if (maxCacheSize > 0 && maxCacheSize < 65535) {
     LOG_INFO("set maxCacheSize to:%d for consumer:%s", maxCacheSize, getGroupName().c_str());
     m_maxMsgCacheSize = maxCacheSize;
   }
 }
 
-int DefaultMQPushConsumer::getMaxCacheMsgSizePerQueue() const {
+int DefaultMQPushConsumerImpl::getMaxCacheMsgSizePerQueue() const {
   return m_maxMsgCacheSize;
 }
 
-ConsumerRunningInfo* DefaultMQPushConsumer::getConsumerRunningInfo() {
+ConsumerRunningInfo* DefaultMQPushConsumerImpl::getConsumerRunningInfo() {
   auto* info = new ConsumerRunningInfo();
   if (m_consumerService->getConsumeMsgSerivceListenerType() == messageListenerOrderly) {
     info->setProperty(ConsumerRunningInfo::PROP_CONSUME_ORDERLY, "true");
@@ -1005,7 +1005,7 @@ ConsumerRunningInfo* DefaultMQPushConsumer::getConsumerRunningInfo() {
   return info;
 }
 // we should deal with name space before producer start.
-bool DefaultMQPushConsumer::dealWithNameSpace() {
+bool DefaultMQPushConsumerImpl::dealWithNameSpace() {
   string ns = getNameSpace();
   if (ns.empty()) {
     string nsAddr = getNamesrvAddr();
diff --git a/include/DefaultMQPushConsumer.h b/src/consumer/DefaultMQPushConsumerImpl.h
similarity index 93%
copy from include/DefaultMQPushConsumer.h
copy to src/consumer/DefaultMQPushConsumerImpl.h
index 7f69258..f90b6cd 100644
--- a/include/DefaultMQPushConsumer.h
+++ b/src/consumer/DefaultMQPushConsumerImpl.h
@@ -1,165 +1,165 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-#ifndef __DEFAULTMQPUSHCONSUMER_H__
-#define __DEFAULTMQPUSHCONSUMER_H__
-
-#include <boost/asio.hpp>
-#include <boost/asio/io_service.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/scoped_ptr.hpp>
-#include <boost/thread/thread.hpp>
-#include <string>
-#include "AsyncCallback.h"
-#include "MQConsumer.h"
-#include "MQMessageListener.h"
-#include "MQMessageQueue.h"
-
-namespace rocketmq {
-
-class Rebalance;
-class SubscriptionData;
-class OffsetStore;
-class PullAPIWrapper;
-class PullRequest;
-class ConsumeMsgService;
-class TaskQueue;
-class TaskThread;
-class AsyncPullCallback;
-class ConsumerRunningInfo;
-//<!***************************************************************************
-class ROCKETMQCLIENT_API DefaultMQPushConsumer : public MQConsumer {
- public:
-  DefaultMQPushConsumer(const std::string& groupname);
-  void boost_asio_work();
-  virtual ~DefaultMQPushConsumer();
-
-  //<!begin mqadmin;
-  virtual void start();
-  virtual void shutdown();
-  //<!end mqadmin;
-
-  //<!begin MQConsumer
-  virtual bool sendMessageBack(MQMessageExt& msg, int delayLevel, std::string& brokerName);
-  virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs);
-  virtual void doRebalance();
-  virtual void persistConsumerOffset();
-  virtual void persistConsumerOffsetByResetOffset();
-  virtual void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info);
-  virtual ConsumeType getConsumeType();
-  virtual ConsumeFromWhere getConsumeFromWhere();
-  void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere);
-  virtual void getSubscriptions(std::vector<SubscriptionData>&);
-  virtual void updateConsumeOffset(const MQMessageQueue& mq, int64 offset);
-  virtual void removeConsumeOffset(const MQMessageQueue& mq);
-  virtual PullResult pull(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums) {
-    return PullResult();
-  }
-  virtual void pull(const MQMessageQueue& mq,
-                    const std::string& subExpression,
-                    int64 offset,
-                    int maxNums,
-                    PullCallback* pPullCallback) {}
-  virtual ConsumerRunningInfo* getConsumerRunningInfo();
-  //<!end MQConsumer;
-
-  void registerMessageListener(MQMessageListener* pMessageListener);
-  MessageListenerType getMessageListenerType();
-  void subscribe(const std::string& topic, const std::string& subExpression);
-
-  OffsetStore* getOffsetStore() const;
-  virtual Rebalance* getRebalance() const;
-  ConsumeMsgService* getConsumerMsgService() const;
-
-  virtual bool producePullMsgTask(boost::weak_ptr<PullRequest>);
-  virtual bool producePullMsgTaskLater(boost::weak_ptr<PullRequest>, int millis);
-  static void static_triggerNextPullRequest(void* context,
-                                            boost::asio::deadline_timer* t,
-                                            boost::weak_ptr<PullRequest>);
-  void triggerNextPullRequest(boost::asio::deadline_timer* t, boost::weak_ptr<PullRequest>);
-  void runPullMsgQueue(TaskQueue* pTaskQueue);
-  void pullMessage(boost::weak_ptr<PullRequest> pullrequest);
-  void pullMessageAsync(boost::weak_ptr<PullRequest> pullrequest);
-  void setAsyncPull(bool asyncFlag);
-  AsyncPullCallback* getAsyncPullCallBack(boost::weak_ptr<PullRequest>, MQMessageQueue msgQueue);
-  void shutdownAsyncPullCallBack();
-
-  /*
-    for orderly consume, set the pull num of message size by each pullMsg,
-    default value is 1;
-  */
-  void setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize);
-  int getConsumeMessageBatchMaxSize() const;
-
-  /*
-    set consuming thread count, default value is cpu cores
-  */
-  void setConsumeThreadCount(int threadCount);
-  int getConsumeThreadCount() const;
-  void setMaxReconsumeTimes(int maxReconsumeTimes);
-  int getMaxReconsumeTimes() const;
-
-  /*
-    set pullMsg thread count, default value is cpu cores
-  */
-  void setPullMsgThreadPoolCount(int threadCount);
-  int getPullMsgThreadPoolCount() const;
-
-  /*
-    set max cache msg size perQueue in memory if consumer could not consume msgs
-    immediately
-    default maxCacheMsgSize perQueue is 1000, set range is:1~65535
-  */
-  void setMaxCacheMsgSizePerQueue(int maxCacheSize);
-  int getMaxCacheMsgSizePerQueue() const;
-
- private:
-  void checkConfig();
-  void copySubscription();
-  void updateTopicSubscribeInfoWhenSubscriptionChanged();
-  bool dealWithNameSpace();
-
- private:
-  uint64_t m_startTime;
-  ConsumeFromWhere m_consumeFromWhere;
-  std::map<std::string, std::string> m_subTopics;
-  int m_consumeThreadCount;
-  OffsetStore* m_pOffsetStore;
-  Rebalance* m_pRebalance;
-  PullAPIWrapper* m_pPullAPIWrapper;
-  ConsumeMsgService* m_consumerService;
-  MQMessageListener* m_pMessageListener;
-  int m_consumeMessageBatchMaxSize;
-  int m_maxMsgCacheSize;
-  int m_maxReconsumeTimes = -1;
-  boost::asio::io_service m_async_ioService;
-  boost::scoped_ptr<boost::thread> m_async_service_thread;
-
-  typedef std::map<MQMessageQueue, AsyncPullCallback*> PullMAP;
-  PullMAP m_PullCallback;
-  bool m_asyncPull;
-  int m_asyncPullTimeout;
-  int m_pullMsgThreadPoolNum;
-
- private:
-  TaskQueue* m_pullmsgQueue;
-  std::unique_ptr<boost::thread> m_pullmsgThread;
-};
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#ifndef __DEFAULTMQPUSHCONSUMERIMPL_H__
+#define __DEFAULTMQPUSHCONSUMERIMPL_H__
+
+#include <boost/asio.hpp>
+#include <boost/asio/io_service.hpp>
+#include <boost/bind.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/thread/thread.hpp>
+#include <string>
+#include "AsyncCallback.h"
+#include "MQConsumer.h"
+#include "MQMessageListener.h"
+#include "MQMessageQueue.h"
+
+namespace rocketmq {
+
+class Rebalance;
+class SubscriptionData;
+class OffsetStore;
+class PullAPIWrapper;
+class PullRequest;
+class ConsumeMsgService;
+class TaskQueue;
+class TaskThread;
+class AsyncPullCallback;
+class ConsumerRunningInfo;
+//<!***************************************************************************
+class DefaultMQPushConsumerImpl : public MQConsumer {
+ public:
+  DefaultMQPushConsumerImpl(const std::string& groupname);
+  void boost_asio_work();
+  virtual ~DefaultMQPushConsumerImpl();
+
+  //<!begin mqadmin;
+  virtual void start();
+  virtual void shutdown();
+  //<!end mqadmin;
+
+  //<!begin MQConsumer
+  virtual bool sendMessageBack(MQMessageExt& msg, int delayLevel, std::string& brokerName);
+  virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs);
+  virtual void doRebalance();
+  virtual void persistConsumerOffset();
+  virtual void persistConsumerOffsetByResetOffset();
+  virtual void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info);
+  virtual ConsumeType getConsumeType();
+  virtual ConsumeFromWhere getConsumeFromWhere();
+  void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere);
+  virtual void getSubscriptions(std::vector<SubscriptionData>&);
+  virtual void updateConsumeOffset(const MQMessageQueue& mq, int64 offset);
+  virtual void removeConsumeOffset(const MQMessageQueue& mq);
+  virtual PullResult pull(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums) {
+    return PullResult();
+  }
+  virtual void pull(const MQMessageQueue& mq,
+                    const std::string& subExpression,
+                    int64 offset,
+                    int maxNums,
+                    PullCallback* pPullCallback) {}
+  virtual ConsumerRunningInfo* getConsumerRunningInfo();
+  //<!end MQConsumer;
+
+  void registerMessageListener(MQMessageListener* pMessageListener);
+  MessageListenerType getMessageListenerType();
+  void subscribe(const std::string& topic, const std::string& subExpression);
+
+  OffsetStore* getOffsetStore() const;
+  virtual Rebalance* getRebalance() const;
+  ConsumeMsgService* getConsumerMsgService() const;
+
+  virtual bool producePullMsgTask(boost::weak_ptr<PullRequest>);
+  virtual bool producePullMsgTaskLater(boost::weak_ptr<PullRequest>, int millis);
+  static void static_triggerNextPullRequest(void* context,
+                                            boost::asio::deadline_timer* t,
+                                            boost::weak_ptr<PullRequest>);
+  void triggerNextPullRequest(boost::asio::deadline_timer* t, boost::weak_ptr<PullRequest>);
+  void runPullMsgQueue(TaskQueue* pTaskQueue);
+  void pullMessage(boost::weak_ptr<PullRequest> pullrequest);
+  void pullMessageAsync(boost::weak_ptr<PullRequest> pullrequest);
+  void setAsyncPull(bool asyncFlag);
+  AsyncPullCallback* getAsyncPullCallBack(boost::weak_ptr<PullRequest>, MQMessageQueue msgQueue);
+  void shutdownAsyncPullCallBack();
+
+  /*
+    for orderly consume, set the pull num of message size by each pullMsg,
+    default value is 1;
+  */
+  void setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize);
+  int getConsumeMessageBatchMaxSize() const;
+
+  /*
+    set consuming thread count, default value is cpu cores
+  */
+  void setConsumeThreadCount(int threadCount);
+  int getConsumeThreadCount() const;
+  void setMaxReconsumeTimes(int maxReconsumeTimes);
+  int getMaxReconsumeTimes() const;
+
+  /*
+    set pullMsg thread count, default value is cpu cores
+  */
+  void setPullMsgThreadPoolCount(int threadCount);
+  int getPullMsgThreadPoolCount() const;
+
+  /*
+    set max cache msg size perQueue in memory if consumer could not consume msgs
+    immediately
+    default maxCacheMsgSize perQueue is 1000, set range is:1~65535
+  */
+  void setMaxCacheMsgSizePerQueue(int maxCacheSize);
+  int getMaxCacheMsgSizePerQueue() const;
+
+ private:
+  void checkConfig();
+  void copySubscription();
+  void updateTopicSubscribeInfoWhenSubscriptionChanged();
+  bool dealWithNameSpace();
+
+ private:
+  uint64_t m_startTime;
+  ConsumeFromWhere m_consumeFromWhere;
+  std::map<std::string, std::string> m_subTopics;
+  int m_consumeThreadCount;
+  OffsetStore* m_pOffsetStore;
+  Rebalance* m_pRebalance;
+  PullAPIWrapper* m_pPullAPIWrapper;
+  ConsumeMsgService* m_consumerService;
+  MQMessageListener* m_pMessageListener;
+  int m_consumeMessageBatchMaxSize;
+  int m_maxMsgCacheSize;
+  int m_maxReconsumeTimes = -1;
+  boost::asio::io_service m_async_ioService;
+  boost::scoped_ptr<boost::thread> m_async_service_thread;
+
+  typedef std::map<MQMessageQueue, AsyncPullCallback*> PullMAP;
+  PullMAP m_PullCallback;
+  bool m_asyncPull;
+  int m_asyncPullTimeout;
+  int m_pullMsgThreadPoolNum;
+
+ private:
+  TaskQueue* m_pullmsgQueue;
+  std::unique_ptr<boost::thread> m_pullmsgThread;
+};
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif
diff --git a/src/consumer/Rebalance.cpp b/src/consumer/Rebalance.cpp
index 5546b61..f930362 100644
--- a/src/consumer/Rebalance.cpp
+++ b/src/consumer/Rebalance.cpp
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 #include "Rebalance.h"
-#include "DefaultMQPushConsumer.h"
+#include "DefaultMQPushConsumerImpl.h"
 #include "LockBatchBody.h"
 #include "Logging.h"
 #include "MQClientAPIImpl.h"
@@ -150,7 +150,7 @@ void Rebalance::doRebalance() {
 }
 
 void Rebalance::persistConsumerOffset() {
-  DefaultMQPushConsumer* pConsumer = static_cast<DefaultMQPushConsumer*>(m_pConsumer);
+  DefaultMQPushConsumerImpl* pConsumer = static_cast<DefaultMQPushConsumerImpl*>(m_pConsumer);
   OffsetStore* pOffsetStore = pConsumer->getOffsetStore();
   vector<MQMessageQueue> mqs;
   {
@@ -174,7 +174,7 @@ void Rebalance::persistConsumerOffset() {
 }
 
 void Rebalance::persistConsumerOffsetByResetOffset() {
-  DefaultMQPushConsumer* pConsumer = static_cast<DefaultMQPushConsumer*>(m_pConsumer);
+  DefaultMQPushConsumerImpl* pConsumer = static_cast<DefaultMQPushConsumerImpl*>(m_pConsumer);
   OffsetStore* pOffsetStore = pConsumer->getOffsetStore();
   vector<MQMessageQueue> mqs;
   {
@@ -552,7 +552,7 @@ bool RebalancePush::updateRequestTableInRebalance(const string& topic, vector<MQ
 
 int64 RebalancePush::computePullFromWhere(const MQMessageQueue& mq) {
   int64 result = -1;
-  DefaultMQPushConsumer* pConsumer = dynamic_cast<DefaultMQPushConsumer*>(m_pConsumer);
+  DefaultMQPushConsumerImpl* pConsumer = dynamic_cast<DefaultMQPushConsumerImpl*>(m_pConsumer);
   if (!pConsumer) {
     LOG_ERROR("Cast consumer pointer to DefaultMQPushConsumer pointer failed when computePullFromWhere %s",
               mq.toString().c_str());
@@ -639,7 +639,7 @@ void RebalancePush::messageQueueChanged(const string& topic,
 
 void RebalancePush::removeUnnecessaryMessageQueue(const MQMessageQueue& mq) {
   // DefaultMQPushConsumer *pConsumer = static_cast<DefaultMQPushConsumer *>(m_pConsumer);
-  DefaultMQPushConsumer* pConsumer = dynamic_cast<DefaultMQPushConsumer*>(m_pConsumer);
+  DefaultMQPushConsumerImpl* pConsumer = dynamic_cast<DefaultMQPushConsumerImpl*>(m_pConsumer);
   if (!pConsumer) {
     LOG_ERROR("Cast  MQConsumer* to DefaultMQPushConsumer* failed when remove %s", mq.toString().c_str());
     return;
diff --git a/src/extern/CMessageExt.cpp b/src/extern/CMessageExt.cpp
index 03a5e2d..a013b84 100644
--- a/src/extern/CMessageExt.cpp
+++ b/src/extern/CMessageExt.cpp
@@ -15,9 +15,9 @@
  * limitations under the License.
  */
 
-#include "MQMessageExt.h"
 #include "CMessageExt.h"
 #include "CCommon.h"
+#include "MQMessageExt.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/extern/CProducer.cpp b/src/extern/CProducer.cpp
index 397d772..e230257 100644
--- a/src/extern/CProducer.cpp
+++ b/src/extern/CProducer.cpp
@@ -27,6 +27,7 @@
 #include "CMessage.h"
 #include "CSendResult.h"
 #include "DefaultMQProducer.h"
+#include "MQClient.h"
 #include "MQClientErrorContainer.h"
 #include "TransactionListener.h"
 #include "TransactionMQProducer.h"
diff --git a/include/BatchMessage.h b/src/include/BatchMessage.h
similarity index 100%
rename from include/BatchMessage.h
rename to src/include/BatchMessage.h
diff --git a/include/MQClient.h b/src/include/DefaultMQClient.h
similarity index 92%
copy from include/MQClient.h
copy to src/include/DefaultMQClient.h
index 0e23339..0ae4934 100644
--- a/include/MQClient.h
+++ b/src/include/DefaultMQClient.h
@@ -1,202 +1,193 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-#ifndef __MQADMIN_H__
-#define __MQADMIN_H__
-#include <boost/asio.hpp>
-#include <boost/asio/io_service.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
-#include "MQMessageExt.h"
-#include "MQMessageQueue.h"
-#include "QueryResult.h"
-#include "RocketMQClient.h"
-#include "SessionCredentials.h"
-
-namespace rocketmq {
-class MQClientFactory;
-//<!***************************************************************************
-
-enum elogLevel {
-  eLOG_LEVEL_FATAL = 1,
-  eLOG_LEVEL_ERROR = 2,
-  eLOG_LEVEL_WARN = 3,
-  eLOG_LEVEL_INFO = 4,
-  eLOG_LEVEL_DEBUG = 5,
-  eLOG_LEVEL_TRACE = 6,
-  eLOG_LEVEL_LEVEL_NUM = 7
-};
-
-class ROCKETMQCLIENT_API MQClient {
- public:
-  MQClient();
-  virtual ~MQClient();
-
- public:
-  // clientid=processId-ipAddr@instanceName;
-  std::string getMQClientId() const;
-  const std::string& getNamesrvAddr() const;
-  void setNamesrvAddr(const std::string& namesrvAddr);
-  const std::string& getNamesrvDomain() const;
-  void setNamesrvDomain(const std::string& namesrvDomain);
-  const std::string& getInstanceName() const;
-  void setInstanceName(const std::string& instanceName);
-  // nameSpace
-  const std::string& getNameSpace() const;
-  void setNameSpace(const std::string& nameSpace);
-  const std::string& getGroupName() const;
-  void setGroupName(const std::string& groupname);
-
-  /**
-   * no realization
-   */
-  void createTopic(const std::string& key, const std::string& newTopic, int queueNum);
-  /**
-   * search earliest msg store time for specified queue
-   *
-   * @param mq
-   *            message queue
-   * @return earliest store time, ms
-   */
-  int64 earliestMsgStoreTime(const MQMessageQueue& mq);
-  /**
-   * search maxOffset of queue
-   *
-   * @param mq
-   *            message queue
-   * @return minOffset of queue
-   */
-  int64 minOffset(const MQMessageQueue& mq);
-  /**
-   * search maxOffset of queue
-   * Note: maxOffset-1 is max offset that could get msg
-   * @param mq
-   *            message queue
-   * @return maxOffset of queue
-   */
-  int64 maxOffset(const MQMessageQueue& mq);
-  /**
-   * get queue offset by timestamp
-   *
-   * @param mq
-   *            mq queue
-   * @param timestamp
-   *            timestamp with ms unit
-   * @return queue offset according to timestamp
-   */
-  int64 searchOffset(const MQMessageQueue& mq, uint64_t timestamp);
-  /**
-   * get whole msg info from broker by msgId
-   *
-   * @param msgId
-   * @return MQMessageExt
-   */
-  MQMessageExt* viewMessage(const std::string& msgId);
-  /**
-   * query message by topic and key
-   *
-   * @param topic
-   *            topic name
-   * @param key
-   *            topic key
-   * @param maxNum
-   *            query num
-   * @param begin
-   *            begin timestamp
-   * @param end
-   *            end timestamp
-   * @return
-   *            according to QueryResult
-   */
-  QueryResult queryMessage(const std::string& topic, const std::string& key, int maxNum, int64 begin, int64 end);
-
-  std::vector<MQMessageQueue> getTopicMessageQueueInfo(const std::string& topic);
-
-  // log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
-  // log file num is 3, each log size is 100M
-  void setLogLevel(elogLevel inputLevel);
-  elogLevel getLogLevel();
-  void setLogFileSizeAndNum(int fileNum, long perFileSize);  // perFileSize is MB unit
-
-  /** set TcpTransport pull thread num, which dermine the num of threads to
- distribute network data,
-     1. its default value is CPU num, it must be setted before producer/consumer
- start, minimum value is CPU num;
-     2. this pullThread num must be tested on your environment to find the best
- value for RT of sendMsg or delay time of consume msg before you change it;
-     3. producer and consumer need different pullThread num, if set this num,
- producer and consumer must set different instanceName.
-     4. configuration suggestion:
-         1>. minimum RT of sendMsg:
-                 pullThreadNum = brokerNum*2
- **/
-  void setTcpTransportPullThreadNum(int num);
-  const int getTcpTransportPullThreadNum() const;
-
-  /** timeout of tcp connect, it is same meaning for both producer and consumer;
-      1. default value is 3000ms
-      2. input parameter could only be milliSecond, suggestion value is
-  1000-3000ms;
-  **/
-  void setTcpTransportConnectTimeout(uint64_t timeout);  // ms
-  const uint64_t getTcpTransportConnectTimeout() const;
-
-  /** timeout of tryLock tcpTransport before sendMsg/pullMsg, if timeout,
-  returns NULL
-      1. paremeter unit is ms, default value is 3000ms, the minimun value is
-  1000ms
-          suggestion value is 3000ms;
-      2. if configured with value smaller than 1000ms, the tryLockTimeout value
-  will be setted to 1000ms
-  **/
-  void setTcpTransportTryLockTimeout(uint64_t timeout);  // ms
-  const uint64_t getTcpTransportTryLockTimeout() const;
-
-  void setUnitName(std::string unitName);
-  const std::string& getUnitName();
-
-  void setSessionCredentials(const std::string& input_accessKey,
-                             const std::string& input_secretKey,
-                             const std::string& input_onsChannel);
-  const SessionCredentials& getSessionCredentials() const;
-
- protected:
-  virtual void start();
-  virtual void shutdown();
-  MQClientFactory* getFactory() const;
-  virtual bool isServiceStateOk();
-
- protected:
-  std::string m_namesrvAddr;
-  std::string m_namesrvDomain;
-  std::string m_instanceName;
-  std::string m_nameSpace;
-  std::string m_GroupName;
-  MQClientFactory* m_clientFactory;
-  int m_serviceState;
-  int m_pullThreadNum;
-  uint64_t m_tcpConnectTimeout;           // ms
-  uint64_t m_tcpTransportTryLockTimeout;  // s
-
-  std::string m_unitName;
-  SessionCredentials m_SessionCredentials;
-};
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#ifndef __DEFAULTMQADMIN_H__
+#define __DEFAULTMQADMIN_H__
+#include <boost/asio.hpp>
+#include <boost/asio/io_service.hpp>
+#include <boost/bind.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include "MQClient.h"
+#include "MQMessageExt.h"
+#include "MQMessageQueue.h"
+#include "QueryResult.h"
+#include "RocketMQClient.h"
+#include "SessionCredentials.h"
+
+namespace rocketmq {
+class MQClientFactory;
+//<!***************************************************************************
+
+class DefaultMQClient {
+ public:
+  DefaultMQClient();
+  virtual ~DefaultMQClient();
+
+ public:
+  // clientid=processId-ipAddr@instanceName;
+  std::string getMQClientId() const;
+  const std::string& getNamesrvAddr() const;
+  void setNamesrvAddr(const std::string& namesrvAddr);
+  const std::string& getNamesrvDomain() const;
+  void setNamesrvDomain(const std::string& namesrvDomain);
+  const std::string& getInstanceName() const;
+  void setInstanceName(const std::string& instanceName);
+  // nameSpace
+  const std::string& getNameSpace() const;
+  void setNameSpace(const std::string& nameSpace);
+  const std::string& getGroupName() const;
+  void setGroupName(const std::string& groupname);
+
+  /**
+   * no realization
+   */
+  void createTopic(const std::string& key, const std::string& newTopic, int queueNum);
+  /**
+   * search earliest msg store time for specified queue
+   *
+   * @param mq
+   *            message queue
+   * @return earliest store time, ms
+   */
+  int64 earliestMsgStoreTime(const MQMessageQueue& mq);
+  /**
+   * search maxOffset of queue
+   *
+   * @param mq
+   *            message queue
+   * @return minOffset of queue
+   */
+  int64 minOffset(const MQMessageQueue& mq);
+  /**
+   * search maxOffset of queue
+   * Note: maxOffset-1 is max offset that could get msg
+   * @param mq
+   *            message queue
+   * @return maxOffset of queue
+   */
+  int64 maxOffset(const MQMessageQueue& mq);
+  /**
+   * get queue offset by timestamp
+   *
+   * @param mq
+   *            mq queue
+   * @param timestamp
+   *            timestamp with ms unit
+   * @return queue offset according to timestamp
+   */
+  int64 searchOffset(const MQMessageQueue& mq, uint64_t timestamp);
+  /**
+   * get whole msg info from broker by msgId
+   *
+   * @param msgId
+   * @return MQMessageExt
+   */
+  MQMessageExt* viewMessage(const std::string& msgId);
+  /**
+   * query message by topic and key
+   *
+   * @param topic
+   *            topic name
+   * @param key
+   *            topic key
+   * @param maxNum
+   *            query num
+   * @param begin
+   *            begin timestamp
+   * @param end
+   *            end timestamp
+   * @return
+   *            according to QueryResult
+   */
+  QueryResult queryMessage(const std::string& topic, const std::string& key, int maxNum, int64 begin, int64 end);
+
+  std::vector<MQMessageQueue> getTopicMessageQueueInfo(const std::string& topic);
+
+  // log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
+  // log file num is 3, each log size is 100M
+  void setLogLevel(elogLevel inputLevel);
+  elogLevel getLogLevel();
+  void setLogFileSizeAndNum(int fileNum, long perFileSize);  // perFileSize is MB unit
+
+  /** set TcpTransport pull thread num, which dermine the num of threads to
+ distribute network data,
+     1. its default value is CPU num, it must be setted before producer/consumer
+ start, minimum value is CPU num;
+     2. this pullThread num must be tested on your environment to find the best
+ value for RT of sendMsg or delay time of consume msg before you change it;
+     3. producer and consumer need different pullThread num, if set this num,
+ producer and consumer must set different instanceName.
+     4. configuration suggestion:
+         1>. minimum RT of sendMsg:
+                 pullThreadNum = brokerNum*2
+ **/
+  void setTcpTransportPullThreadNum(int num);
+  const int getTcpTransportPullThreadNum() const;
+
+  /** timeout of tcp connect, it is same meaning for both producer and consumer;
+      1. default value is 3000ms
+      2. input parameter could only be milliSecond, suggestion value is
+  1000-3000ms;
+  **/
+  void setTcpTransportConnectTimeout(uint64_t timeout);  // ms
+  const uint64_t getTcpTransportConnectTimeout() const;
+
+  /** timeout of tryLock tcpTransport before sendMsg/pullMsg, if timeout,
+  returns NULL
+      1. paremeter unit is ms, default value is 3000ms, the minimun value is
+  1000ms
+          suggestion value is 3000ms;
+      2. if configured with value smaller than 1000ms, the tryLockTimeout value
+  will be setted to 1000ms
+  **/
+  void setTcpTransportTryLockTimeout(uint64_t timeout);  // ms
+  const uint64_t getTcpTransportTryLockTimeout() const;
+
+  void setUnitName(std::string unitName);
+  const std::string& getUnitName() const;
+
+  void setSessionCredentials(const std::string& input_accessKey,
+                             const std::string& input_secretKey,
+                             const std::string& input_onsChannel);
+  const SessionCredentials& getSessionCredentials() const;
+
+ protected:
+  virtual void start();
+  virtual void shutdown();
+  MQClientFactory* getFactory() const;
+  virtual bool isServiceStateOk();
+
+ protected:
+  std::string m_namesrvAddr;
+  std::string m_namesrvDomain;
+  std::string m_instanceName;
+  std::string m_nameSpace;
+  std::string m_GroupName;
+  MQClientFactory* m_clientFactory;
+  int m_serviceState;
+  int m_pullThreadNum;
+  uint64_t m_tcpConnectTimeout;           // ms
+  uint64_t m_tcpTransportTryLockTimeout;  // s
+
+  std::string m_unitName;
+  SessionCredentials m_SessionCredentials;
+};
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif
diff --git a/include/MQConsumer.h b/src/include/MQConsumer.h
similarity index 95%
rename from include/MQConsumer.h
rename to src/include/MQConsumer.h
index 87e2c1b..a79e90f 100644
--- a/include/MQConsumer.h
+++ b/src/include/MQConsumer.h
@@ -1,68 +1,68 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-#ifndef __MQCONSUMER_H__
-#define __MQCONSUMER_H__
-
-#include <string>
-#include "AsyncCallback.h"
-#include "ConsumeType.h"
-#include "MQClient.h"
-#include "RocketMQClient.h"
-
-namespace rocketmq {
-class SubscriptionData;
-class PullRequest;
-class Rebalance;
-class ConsumerRunningInfo;
-//<!************************************************************************
-class ROCKETMQCLIENT_API MQConsumer : public MQClient {
- public:
-  virtual ~MQConsumer() {}
-  virtual bool sendMessageBack(MQMessageExt& msg, int delayLevel, std::string& brokerName) = 0;
-  virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs) = 0;
-  virtual void doRebalance() = 0;
-  virtual void persistConsumerOffset() = 0;
-  virtual void persistConsumerOffsetByResetOffset() = 0;
-  virtual void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info) = 0;
-  virtual void updateConsumeOffset(const MQMessageQueue& mq, int64 offset) = 0;
-  virtual void removeConsumeOffset(const MQMessageQueue& mq) = 0;
-  virtual ConsumeType getConsumeType() = 0;
-  virtual ConsumeFromWhere getConsumeFromWhere() = 0;
-  virtual void getSubscriptions(std::vector<SubscriptionData>&) = 0;
-  virtual bool producePullMsgTask(boost::weak_ptr<PullRequest>) = 0;
-  virtual Rebalance* getRebalance() const = 0;
-  virtual PullResult pull(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums) = 0;
-  virtual void pull(const MQMessageQueue& mq,
-                    const std::string& subExpression,
-                    int64 offset,
-                    int maxNums,
-                    PullCallback* pPullCallback) = 0;
-  virtual ConsumerRunningInfo* getConsumerRunningInfo() = 0;
-
- public:
-  MessageModel getMessageModel() const { return m_messageModel; }
-  void setMessageModel(MessageModel messageModel) { m_messageModel = messageModel; }
-  bool isUseNameSpaceMode() const { return m_useNameSpaceMode; }
-
- protected:
-  MessageModel m_messageModel;
-  bool m_useNameSpaceMode = false;
-};
-
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+#ifndef __MQCONSUMER_H__
+#define __MQCONSUMER_H__
+
+#include <string>
+#include "AsyncCallback.h"
+#include "ConsumeType.h"
+#include "DefaultMQClient.h"
+#include "RocketMQClient.h"
+
+namespace rocketmq {
+class SubscriptionData;
+class PullRequest;
+class Rebalance;
+class ConsumerRunningInfo;
+//<!************************************************************************
+class MQConsumer : public DefaultMQClient {
+ public:
+  virtual ~MQConsumer() {}
+  virtual bool sendMessageBack(MQMessageExt& msg, int delayLevel, std::string& brokerName) = 0;
+  virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs) = 0;
+  virtual void doRebalance() = 0;
+  virtual void persistConsumerOffset() = 0;
+  virtual void persistConsumerOffsetByResetOffset() = 0;
+  virtual void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info) = 0;
+  virtual void updateConsumeOffset(const MQMessageQueue& mq, int64 offset) = 0;
+  virtual void removeConsumeOffset(const MQMessageQueue& mq) = 0;
+  virtual ConsumeType getConsumeType() = 0;
+  virtual ConsumeFromWhere getConsumeFromWhere() = 0;
+  virtual void getSubscriptions(std::vector<SubscriptionData>&) = 0;
+  virtual bool producePullMsgTask(boost::weak_ptr<PullRequest>) = 0;
+  virtual Rebalance* getRebalance() const = 0;
+  virtual PullResult pull(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums) = 0;
+  virtual void pull(const MQMessageQueue& mq,
+                    const std::string& subExpression,
+                    int64 offset,
+                    int maxNums,
+                    PullCallback* pPullCallback) = 0;
+  virtual ConsumerRunningInfo* getConsumerRunningInfo() = 0;
+
+ public:
+  MessageModel getMessageModel() const { return m_messageModel; }
+  void setMessageModel(MessageModel messageModel) { m_messageModel = messageModel; }
+  bool isUseNameSpaceMode() const { return m_useNameSpaceMode; }
+
+ protected:
+  MessageModel m_messageModel;
+  bool m_useNameSpaceMode = false;
+};
+
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif
diff --git a/include/MQProducer.h b/src/include/MQProducer.h
similarity index 95%
rename from include/MQProducer.h
rename to src/include/MQProducer.h
index 03e6b19..0f787d7 100644
--- a/include/MQProducer.h
+++ b/src/include/MQProducer.h
@@ -1,61 +1,61 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-#ifndef __MQPRODUCER_H__
-#define __MQPRODUCER_H__
-
-#include "AsyncCallback.h"
-#include "MQClient.h"
-#include "MQMessageQueue.h"
-#include "MQSelector.h"
-#include "RocketMQClient.h"
-#include "SendResult.h"
-
-namespace rocketmq {
-//<!***************************************************************************
-class ROCKETMQCLIENT_API MQProducer : public MQClient {
- public:
-  MQProducer() {}
-  virtual ~MQProducer() {}
-  // if setted bActiveBroker, will search brokers with best service state
-  // firstly, then search brokers that had been sent failed by last time;
-  virtual SendResult send(MQMessage& msg, bool bSelectActiveBroker = false) = 0;
-  virtual SendResult send(MQMessage& msg, const MQMessageQueue& mq) = 0;
-  // strict order msg, if send failed on seleted MessageQueue, throw exception
-  // to up layer
-  virtual SendResult send(MQMessage& msg, MessageQueueSelector* selector, void* arg) = 0;
-  // non-strict order msg, if send failed on seleted MessageQueue, will auto
-  // retry others Broker queues with autoRetryTimes;
-  // if setted bActiveBroker, if send failed on seleted MessageQueue, , and then
-  // search brokers with best service state, lastly will search brokers that had
-  // been sent failed by last time;
-  virtual SendResult send(MQMessage& msg,
-                          MessageQueueSelector* selector,
-                          void* arg,
-                          int autoRetryTimes,
-                          bool bActiveBroker = false) = 0;
-  virtual void send(MQMessage& msg, SendCallback* sendCallback, bool bSelectActiveBroker = false) = 0;
-  virtual void send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* sendCallback) = 0;
-  virtual void send(MQMessage& msg, MessageQueueSelector* selector, void* arg, SendCallback* sendCallback) = 0;
-  virtual SendResult send(std::vector<MQMessage>& msgs) = 0;
-  virtual SendResult send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq) = 0;
-  virtual void sendOneway(MQMessage& msg, bool bSelectActiveBroker = false) = 0;
-  virtual void sendOneway(MQMessage& msg, const MQMessageQueue& mq) = 0;
-  virtual void sendOneway(MQMessage& msg, MessageQueueSelector* selector, void* arg) = 0;
-};
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+#ifndef __MQPRODUCER_H__
+#define __MQPRODUCER_H__
+
+#include "AsyncCallback.h"
+#include "DefaultMQClient.h"
+#include "MQMessageQueue.h"
+#include "MQSelector.h"
+#include "RocketMQClient.h"
+#include "SendResult.h"
+
+namespace rocketmq {
+//<!***************************************************************************
+class MQProducer : public DefaultMQClient {
+ public:
+  MQProducer() {}
+  virtual ~MQProducer() {}
+  // if setted bActiveBroker, will search brokers with best service state
+  // firstly, then search brokers that had been sent failed by last time;
+  virtual SendResult send(MQMessage& msg, bool bSelectActiveBroker = false) = 0;
+  virtual SendResult send(MQMessage& msg, const MQMessageQueue& mq) = 0;
+  // strict order msg, if send failed on seleted MessageQueue, throw exception
+  // to up layer
+  virtual SendResult send(MQMessage& msg, MessageQueueSelector* selector, void* arg) = 0;
+  // non-strict order msg, if send failed on seleted MessageQueue, will auto
+  // retry others Broker queues with autoRetryTimes;
+  // if setted bActiveBroker, if send failed on seleted MessageQueue, , and then
+  // search brokers with best service state, lastly will search brokers that had
+  // been sent failed by last time;
+  virtual SendResult send(MQMessage& msg,
+                          MessageQueueSelector* selector,
+                          void* arg,
+                          int autoRetryTimes,
+                          bool bActiveBroker = false) = 0;
+  virtual void send(MQMessage& msg, SendCallback* sendCallback, bool bSelectActiveBroker = false) = 0;
+  virtual void send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* sendCallback) = 0;
+  virtual void send(MQMessage& msg, MessageQueueSelector* selector, void* arg, SendCallback* sendCallback) = 0;
+  virtual SendResult send(std::vector<MQMessage>& msgs) = 0;
+  virtual SendResult send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq) = 0;
+  virtual void sendOneway(MQMessage& msg, bool bSelectActiveBroker = false) = 0;
+  virtual void sendOneway(MQMessage& msg, const MQMessageQueue& mq) = 0;
+  virtual void sendOneway(MQMessage& msg, MessageQueueSelector* selector, void* arg) = 0;
+};
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif
diff --git a/include/QueryResult.h b/src/include/QueryResult.h
similarity index 97%
rename from include/QueryResult.h
rename to src/include/QueryResult.h
index b7c3697..f03a206 100644
--- a/include/QueryResult.h
+++ b/src/include/QueryResult.h
@@ -1,42 +1,42 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-#ifndef __QUERYRESULT_H__
-#define __QUERYRESULT_H__
-
-#include "MQMessageExt.h"
-#include "RocketMQClient.h"
-
-namespace rocketmq {
-//<!************************************************************************
-class ROCKETMQCLIENT_API QueryResult {
- public:
-  QueryResult(uint64 indexLastUpdateTimestamp, const std::vector<MQMessageExt*>& messageList) {
-    m_indexLastUpdateTimestamp = indexLastUpdateTimestamp;
-    m_messageList = messageList;
-  }
-
-  uint64 getIndexLastUpdateTimestamp() { return m_indexLastUpdateTimestamp; }
-
-  std::vector<MQMessageExt*>& getMessageList() { return m_messageList; }
-
- private:
-  uint64 m_indexLastUpdateTimestamp;
-  std::vector<MQMessageExt*> m_messageList;
-};
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+#ifndef __QUERYRESULT_H__
+#define __QUERYRESULT_H__
+
+#include "MQMessageExt.h"
+#include "RocketMQClient.h"
+
+namespace rocketmq {
+//<!************************************************************************
+class ROCKETMQCLIENT_API QueryResult {
+ public:
+  QueryResult(uint64 indexLastUpdateTimestamp, const std::vector<MQMessageExt*>& messageList) {
+    m_indexLastUpdateTimestamp = indexLastUpdateTimestamp;
+    m_messageList = messageList;
+  }
+
+  uint64 getIndexLastUpdateTimestamp() { return m_indexLastUpdateTimestamp; }
+
+  std::vector<MQMessageExt*>& getMessageList() { return m_messageList; }
+
+ private:
+  uint64 m_indexLastUpdateTimestamp;
+  std::vector<MQMessageExt*> m_messageList;
+};
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif
diff --git a/include/SendMessageHook.h b/src/include/SendMessageHook.h
similarity index 87%
rename from include/SendMessageHook.h
rename to src/include/SendMessageHook.h
index 1af0e92..0d3e1e3 100644
--- a/include/SendMessageHook.h
+++ b/src/include/SendMessageHook.h
@@ -1,47 +1,49 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-#ifndef __SENDMESSAGEHOOK_H__
-#define __SENDMESSAGEHOOK_H__
-
-#include "MQClientException.h"
-#include "MQMessage.h"
-#include "RocketMQClient.h"
-
-namespace rocketmq {
-//<!***************************************************************************
-class ROCKETMQCLIENT_API SendMessageContext {
- public:
-  string producerGroup;
-  MQMessage msg;
-  MQMessageQueue mq;
-  string brokerAddr;
-  int communicationMode;
-  SendResult sendResult;
-  MQException* pException;
-  void* pArg;
-};
-
-class ROCKETMQCLIENT_API SendMessageHook {
- public:
-  virtual ~SendMessageHook() {}
-  virtual string hookName() = 0;
-  virtual void sendMessageBefore(const SendMessageContext& context) = 0;
-  virtual void sendMessageAfter(const SendMessageContext& context) = 0;
-};
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+#ifndef __SENDMESSAGEHOOK_H__
+#define __SENDMESSAGEHOOK_H__
+
+#include "MQClientException.h"
+#include "MQMessage.h"
+#include "MQMessageQueue.h"
+#include "RocketMQClient.h"
+#include "SendResult.h"
+
+namespace rocketmq {
+//<!***************************************************************************
+class SendMessageContext {
+ public:
+  std::string producerGroup;
+  MQMessage msg;
+  MQMessageQueue mq;
+  std::string brokerAddr;
+  int communicationMode;
+  SendResult sendResult;
+  MQException* pException;
+  void* pArg;
+};
+
+class SendMessageHook {
+ public:
+  virtual ~SendMessageHook() {}
+  virtual std::string hookName() = 0;
+  virtual void sendMessageBefore(const SendMessageContext& context) = 0;
+  virtual void sendMessageAfter(const SendMessageContext& context) = 0;
+};
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif
diff --git a/src/log/Logging.h b/src/log/Logging.h
index dfede34..24960c7 100644
--- a/src/log/Logging.h
+++ b/src/log/Logging.h
@@ -31,7 +31,7 @@
 #include <boost/log/utility/setup/file.hpp>
 #include <boost/scoped_array.hpp>
 #include <boost/shared_ptr.hpp>
-#include "MQClient.h"
+#include "include/DefaultMQClient.h"
 
 namespace logging = boost::log;
 namespace src = boost::log::sources;
diff --git a/src/message/BatchMessage.cpp b/src/message/BatchMessage.cpp
index 3a2481b..9bcca1c 100644
--- a/src/message/BatchMessage.cpp
+++ b/src/message/BatchMessage.cpp
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "BatchMessage.h"
+#include "include/BatchMessage.h"
 
 #include "MQDecoder.h"
 #include "StringIdMaker.h"
diff --git a/src/producer/DefaultMQProducer.cpp b/src/producer/DefaultMQProducer.cpp
index ee81a7b..9a6d414 100644
--- a/src/producer/DefaultMQProducer.cpp
+++ b/src/producer/DefaultMQProducer.cpp
@@ -1,635 +1,207 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 "DefaultMQProducer.h"
 
-#include <assert.h>
-#include <typeindex>
-
-#include "BatchMessage.h"
-#include "CommandHeader.h"
-#include "CommunicationMode.h"
-#include "Logging.h"
-#include "MQClientAPIImpl.h"
-#include "MQClientException.h"
-#include "MQClientFactory.h"
-#include "MQClientManager.h"
-#include "MQDecoder.h"
-#include "MQProtos.h"
-#include "MessageAccessor.h"
-#include "NameSpaceUtil.h"
-#include "StringIdMaker.h"
-#include "TopicPublishInfo.h"
-#include "Validators.h"
+#include "DefaultMQProducerImpl.h"
 
 namespace rocketmq {
 
-//<!************************************************************************
-DefaultMQProducer::DefaultMQProducer(const string& groupname)
-    : m_sendMsgTimeout(3000),
-      m_compressMsgBodyOverHowmuch(4 * 1024),
-      m_maxMessageSize(1024 * 128),
-      // m_retryAnotherBrokerWhenNotStoreOK(false),
-      m_compressLevel(5),
-      m_retryTimes(5),
-      m_retryTimes4Async(1) {
-  //<!set default group name;
-  string gname = groupname.empty() ? DEFAULT_PRODUCER_GROUP : groupname;
-  setGroupName(gname);
+DefaultMQProducer::DefaultMQProducer(const std::string& groupName) {
+  impl = new DefaultMQProducerImpl(groupName);
 }
 
-DefaultMQProducer::~DefaultMQProducer() {}
-
+DefaultMQProducer::~DefaultMQProducer() {
+  delete impl;
+}
 void DefaultMQProducer::start() {
-#ifndef WIN32
-  /* Ignore the SIGPIPE */
-  struct sigaction sa;
-  memset(&sa, 0, sizeof(struct sigaction));
-  sa.sa_handler = SIG_IGN;
-  sa.sa_flags = 0;
-  sigaction(SIGPIPE, &sa, 0);
-#endif
-  // we should deal with namespaced before start.
-  dealWithNameSpace();
-  switch (m_serviceState) {
-    case CREATE_JUST: {
-      m_serviceState = START_FAILED;
-      MQClient::start();
-      LOG_INFO("DefaultMQProducer:%s start", m_GroupName.c_str());
-
-      bool registerOK = getFactory()->registerProducer(this);
-      if (!registerOK) {
-        m_serviceState = CREATE_JUST;
-        THROW_MQEXCEPTION(
-            MQClientException,
-            "The producer group[" + getGroupName() + "] has been created before, specify another name please.", -1);
-      }
-
-      getFactory()->start();
-      getFactory()->sendHeartbeatToAllBroker();
-      m_serviceState = RUNNING;
-      break;
-    }
-    case RUNNING:
-    case START_FAILED:
-    case SHUTDOWN_ALREADY:
-      break;
-    default:
-      break;
-  }
+  impl->start();
 }
 
 void DefaultMQProducer::shutdown() {
-  switch (m_serviceState) {
-    case RUNNING: {
-      LOG_INFO("DefaultMQProducer shutdown");
-      getFactory()->unregisterProducer(this);
-      getFactory()->shutdown();
-      m_serviceState = SHUTDOWN_ALREADY;
-      break;
-    }
-    case SHUTDOWN_ALREADY:
-    case CREATE_JUST:
-      break;
-    default:
-      break;
-  }
+  impl->shutdown();
 }
 
-SendResult DefaultMQProducer::send(MQMessage& msg, bool bSelectActiveBroker) {
-  Validators::checkMessage(msg, getMaxMessageSize());
-  if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-    MessageAccessor::withNameSpace(msg, getNameSpace());
-  }
-  try {
-    return sendDefaultImpl(msg, ComMode_SYNC, NULL, bSelectActiveBroker);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
-  return SendResult();
+// start mqclient set
+const std::string& DefaultMQProducer::getNamesrvAddr() const {
+  return impl->getNamesrvAddr();
 }
 
-void DefaultMQProducer::send(MQMessage& msg, SendCallback* pSendCallback, bool bSelectActiveBroker) {
-  Validators::checkMessage(msg, getMaxMessageSize());
-  if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-    MessageAccessor::withNameSpace(msg, getNameSpace());
-  }
-  try {
-    sendDefaultImpl(msg, ComMode_ASYNC, pSendCallback, bSelectActiveBroker);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
+void DefaultMQProducer::setNamesrvAddr(const std::string& namesrvAddr) {
+  impl->setNamesrvAddr(namesrvAddr);
 }
 
-SendResult DefaultMQProducer::send(std::vector<MQMessage>& msgs) {
-  SendResult result;
-  try {
-    BatchMessage batchMessage = buildBatchMessage(msgs);
-    result = sendDefaultImpl(batchMessage, ComMode_SYNC, NULL);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
-  return result;
+const std::string& DefaultMQProducer::getNamesrvDomain() const {
+  return impl->getNamesrvDomain();
 }
 
-SendResult DefaultMQProducer::send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq) {
-  SendResult result;
-  try {
-    BatchMessage batchMessage = buildBatchMessage(msgs);
-    result = sendKernelImpl(batchMessage, mq, ComMode_SYNC, NULL);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
-  return result;
-}
-
-BatchMessage DefaultMQProducer::buildBatchMessage(std::vector<MQMessage>& msgs) {
-  if (msgs.size() < 1) {
-    THROW_MQEXCEPTION(MQClientException, "msgs need one message at least", -1);
-  }
-  BatchMessage batchMessage;
-  bool firstFlag = true;
-  string topic;
-  bool waitStoreMsgOK = false;
-  for (auto& msg : msgs) {
-    Validators::checkMessage(msg, getMaxMessageSize());
-    if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-      MessageAccessor::withNameSpace(msg, getNameSpace());
-    }
-    if (firstFlag) {
-      topic = msg.getTopic();
-      waitStoreMsgOK = msg.isWaitStoreMsgOK();
-      firstFlag = false;
-
-      if (UtilAll::startsWith_retry(topic)) {
-        THROW_MQEXCEPTION(MQClientException, "Retry Group is not supported for batching", -1);
-      }
-    } else {
-      if (msg.getDelayTimeLevel() > 0) {
-        THROW_MQEXCEPTION(MQClientException, "TimeDelayLevel in not supported for batching", -1);
-      }
-      if (msg.getTopic() != topic) {
-        THROW_MQEXCEPTION(MQClientException, "msgs need one message at least", -1);
-      }
-      if (msg.isWaitStoreMsgOK() != waitStoreMsgOK) {
-        THROW_MQEXCEPTION(MQClientException, "msgs need one message at least", -2);
-      }
-    }
-  }
-  batchMessage.setBody(BatchMessage::encode(msgs));
-  batchMessage.setTopic(topic);
-  batchMessage.setWaitStoreMsgOK(waitStoreMsgOK);
-  return batchMessage;
+void DefaultMQProducer::setNamesrvDomain(const std::string& namesrvDomain) {
+  impl->setNamesrvDomain(namesrvDomain);
+}
+void DefaultMQProducer::setSessionCredentials(const std::string& accessKey,
+                                              const std::string& secretKey,
+                                              const std::string& accessChannel) {
+  impl->setSessionCredentials(accessKey, secretKey, accessChannel);
 }
 
-SendResult DefaultMQProducer::send(MQMessage& msg, const MQMessageQueue& mq) {
-  Validators::checkMessage(msg, getMaxMessageSize());
-  if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-    MessageAccessor::withNameSpace(msg, getNameSpace());
-  }
-  if (msg.getTopic() != mq.getTopic()) {
-    LOG_WARN("message's topic not equal mq's topic");
-  }
-  try {
-    return sendKernelImpl(msg, mq, ComMode_SYNC, NULL);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
-  return SendResult();
+const SessionCredentials& DefaultMQProducer::getSessionCredentials() const {
+  return impl->getSessionCredentials();
+}
+const std::string& DefaultMQProducer::getInstanceName() const {
+  return impl->getInstanceName();
 }
 
-void DefaultMQProducer::send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* pSendCallback) {
-  Validators::checkMessage(msg, getMaxMessageSize());
-  if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-    MessageAccessor::withNameSpace(msg, getNameSpace());
-  }
-  if (msg.getTopic() != mq.getTopic()) {
-    LOG_WARN("message's topic not equal mq's topic");
-  }
-  try {
-    sendKernelImpl(msg, mq, ComMode_ASYNC, pSendCallback);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
+void DefaultMQProducer::setInstanceName(const std::string& instanceName) {
+  impl->setInstanceName(instanceName);
 }
 
-void DefaultMQProducer::sendOneway(MQMessage& msg, bool bSelectActiveBroker) {
-  Validators::checkMessage(msg, getMaxMessageSize());
-  if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-    MessageAccessor::withNameSpace(msg, getNameSpace());
-  }
-  try {
-    sendDefaultImpl(msg, ComMode_ONEWAY, NULL, bSelectActiveBroker);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
+const std::string& DefaultMQProducer::getNameSpace() const {
+  return impl->getNameSpace();
 }
 
-void DefaultMQProducer::sendOneway(MQMessage& msg, const MQMessageQueue& mq) {
-  Validators::checkMessage(msg, getMaxMessageSize());
-  if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-    MessageAccessor::withNameSpace(msg, getNameSpace());
-  }
-  if (msg.getTopic() != mq.getTopic()) {
-    LOG_WARN("message's topic not equal mq's topic");
-  }
-  try {
-    sendKernelImpl(msg, mq, ComMode_ONEWAY, NULL);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
-}
-
-SendResult DefaultMQProducer::send(MQMessage& msg, MessageQueueSelector* pSelector, void* arg) {
-  try {
-    if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-      MessageAccessor::withNameSpace(msg, getNameSpace());
-    }
-    return sendSelectImpl(msg, pSelector, arg, ComMode_SYNC, NULL);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
-  return SendResult();
+void DefaultMQProducer::setNameSpace(const std::string& nameSpace) {
+  impl->setNameSpace(nameSpace);
+}
+const std::string& DefaultMQProducer::getGroupName() const {
+  return impl->getGroupName();
 }
 
-SendResult DefaultMQProducer::send(MQMessage& msg,
-                                   MessageQueueSelector* pSelector,
-                                   void* arg,
-                                   int autoRetryTimes,
-                                   bool bActiveBroker) {
-  try {
-    if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-      MessageAccessor::withNameSpace(msg, getNameSpace());
-    }
-    return sendAutoRetrySelectImpl(msg, pSelector, arg, ComMode_SYNC, NULL, autoRetryTimes, bActiveBroker);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
-  return SendResult();
-}
-
-void DefaultMQProducer::send(MQMessage& msg, MessageQueueSelector* pSelector, void* arg, SendCallback* pSendCallback) {
-  try {
-    if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-      MessageAccessor::withNameSpace(msg, getNameSpace());
-    }
-    sendSelectImpl(msg, pSelector, arg, ComMode_ASYNC, pSendCallback);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
-}
-
-void DefaultMQProducer::sendOneway(MQMessage& msg, MessageQueueSelector* pSelector, void* arg) {
-  try {
-    if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
-      MessageAccessor::withNameSpace(msg, getNameSpace());
-    }
-    sendSelectImpl(msg, pSelector, arg, ComMode_ONEWAY, NULL);
-  } catch (MQException& e) {
-    LOG_ERROR(e.what());
-    throw e;
-  }
+void DefaultMQProducer::setGroupName(const std::string& groupName) {
+  impl->setGroupName(groupName);
+}
+void DefaultMQProducer::setSendMsgTimeout(int sendMsgTimeout) {
+  impl->setSendMsgTimeout(sendMsgTimeout);
 }
 
 int DefaultMQProducer::getSendMsgTimeout() const {
-  return m_sendMsgTimeout;
+  return impl->getSendMsgTimeout();
 }
 
-void DefaultMQProducer::setSendMsgTimeout(int sendMsgTimeout) {
-  m_sendMsgTimeout = sendMsgTimeout;
+void DefaultMQProducer::setRetryTimes(int times) {
+  impl->setRetryTimes(times);
+}
+
+int DefaultMQProducer::getRetryTimes() const {
+  return impl->getRetryTimes();
 }
 
 int DefaultMQProducer::getCompressMsgBodyOverHowmuch() const {
-  return m_compressMsgBodyOverHowmuch;
+  return impl->getCompressMsgBodyOverHowmuch();
 }
 
-void DefaultMQProducer::setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
-  m_compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
+void DefaultMQProducer::setCompressMsgBodyOverHowmuch(int compressMsgBodyThreshold) {
+  impl->setCompressMsgBodyOverHowmuch(compressMsgBodyThreshold);
 }
 
-int DefaultMQProducer::getMaxMessageSize() const {
-  return m_maxMessageSize;
+int DefaultMQProducer::getCompressLevel() const {
+  return impl->getCompressLevel();
+}
+
+void DefaultMQProducer::setCompressLevel(int compressLevel) {
+  impl->setCompressLevel(compressLevel);
 }
 
 void DefaultMQProducer::setMaxMessageSize(int maxMessageSize) {
-  m_maxMessageSize = maxMessageSize;
+  impl->setMaxMessageSize(maxMessageSize);
 }
 
-int DefaultMQProducer::getCompressLevel() const {
-  return m_compressLevel;
+int DefaultMQProducer::getMaxMessageSize() const {
+  return impl->getMaxMessageSize();
 }
 
-void DefaultMQProducer::setCompressLevel(int compressLevel) {
-  assert((compressLevel >= 0 && compressLevel <= 9) || compressLevel == -1);
-
-  m_compressLevel = compressLevel;
-}
-
-//<!************************************************************************
-SendResult DefaultMQProducer::sendDefaultImpl(MQMessage& msg,
-                                              int communicationMode,
-                                              SendCallback* pSendCallback,
-                                              bool bActiveMQ) {
-  MQMessageQueue lastmq;
-  int mq_index = 0;
-  for (int times = 1; times <= m_retryTimes; times++) {
-    boost::weak_ptr<TopicPublishInfo> weak_topicPublishInfo(
-        getFactory()->tryToFindTopicPublishInfo(msg.getTopic(), getSessionCredentials()));
-    boost::shared_ptr<TopicPublishInfo> topicPublishInfo(weak_topicPublishInfo.lock());
-    if (topicPublishInfo) {
-      if (times == 1) {
-        mq_index = topicPublishInfo->getWhichQueue();
-      } else {
-        mq_index++;
-      }
-
-      SendResult sendResult;
-      MQMessageQueue mq;
-      if (bActiveMQ)
-        mq = topicPublishInfo->selectOneActiveMessageQueue(lastmq, mq_index);
-      else
-        mq = topicPublishInfo->selectOneMessageQueue(lastmq, mq_index);
-
-      lastmq = mq;
-      if (mq.getQueueId() == -1) {
-        // THROW_MQEXCEPTION(MQClientException, "the MQMessageQueue is
-        // invalide", -1);
-        continue;
-      }
-
-      try {
-        LOG_DEBUG("send to mq:%s", mq.toString().data());
-        sendResult = sendKernelImpl(msg, mq, communicationMode, pSendCallback);
-        switch (communicationMode) {
-          case ComMode_ASYNC:
-            return sendResult;
-          case ComMode_ONEWAY:
-            return sendResult;
-          case ComMode_SYNC:
-            if (sendResult.getSendStatus() != SEND_OK) {
-              if (bActiveMQ) {
-                topicPublishInfo->updateNonServiceMessageQueue(mq, getSendMsgTimeout());
-              }
-              continue;
-            }
-            return sendResult;
-          default:
-            break;
-        }
-      } catch (...) {
-        LOG_ERROR("send failed of times:%d,brokerName:%s", times, mq.getBrokerName().c_str());
-        if (bActiveMQ) {
-          topicPublishInfo->updateNonServiceMessageQueue(mq, getSendMsgTimeout());
-        }
-        continue;
-      }
-    }  // end of for
-    LOG_WARN("Retry many times, still failed");
-  }
-  string info = "No route info of this topic: " + msg.getTopic();
-  THROW_MQEXCEPTION(MQClientException, info, -1);
-}
-
-SendResult DefaultMQProducer::sendKernelImpl(MQMessage& msg,
-                                             const MQMessageQueue& mq,
-                                             int communicationMode,
-                                             SendCallback* sendCallback) {
-  string brokerAddr = getFactory()->findBrokerAddressInPublish(mq.getBrokerName());
-
-  if (brokerAddr.empty()) {
-    getFactory()->tryToFindTopicPublishInfo(mq.getTopic(), getSessionCredentials());
-    brokerAddr = getFactory()->findBrokerAddressInPublish(mq.getBrokerName());
-  }
-
-  if (!brokerAddr.empty()) {
-    try {
-      bool isBatchMsg = std::type_index(typeid(msg)) == std::type_index(typeid(BatchMessage));
-      // msgId is produced by client, offsetMsgId produced by broker. (same with java sdk)
-      if (!isBatchMsg) {
-        string unique_id = StringIdMaker::getInstance().createUniqID();
-        msg.setProperty(MQMessage::PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX, unique_id);
-
-        // batch does not support compressing right now,
-        tryToCompressMessage(msg);
-      }
-
-      LOG_DEBUG("produce before:%s to %s", msg.toString().c_str(), mq.toString().c_str());
-
-      SendMessageRequestHeader* requestHeader = new SendMessageRequestHeader();
-      requestHeader->producerGroup = getGroupName();
-      requestHeader->topic = (msg.getTopic());
-      requestHeader->defaultTopic = DEFAULT_TOPIC;
-      requestHeader->defaultTopicQueueNums = 4;
-      requestHeader->queueId = (mq.getQueueId());
-      requestHeader->sysFlag = (msg.getSysFlag());
-      requestHeader->bornTimestamp = UtilAll::currentTimeMillis();
-      requestHeader->flag = (msg.getFlag());
-      requestHeader->consumeRetryTimes = 16;
-      requestHeader->batch = isBatchMsg;
-      requestHeader->properties = (MQDecoder::messageProperties2String(msg.getProperties()));
-
-      return getFactory()->getMQClientAPIImpl()->sendMessage(brokerAddr, mq.getBrokerName(), msg, requestHeader,
-                                                             getSendMsgTimeout(), getRetryTimes4Async(),
-                                                             communicationMode, sendCallback, getSessionCredentials());
-    } catch (MQException& e) {
-      throw e;
-    }
-  }
-  THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
-}
-
-SendResult DefaultMQProducer::sendSelectImpl(MQMessage& msg,
-                                             MessageQueueSelector* pSelector,
-                                             void* pArg,
-                                             int communicationMode,
-                                             SendCallback* sendCallback) {
-  Validators::checkMessage(msg, getMaxMessageSize());
-
-  boost::weak_ptr<TopicPublishInfo> weak_topicPublishInfo(
-      getFactory()->tryToFindTopicPublishInfo(msg.getTopic(), getSessionCredentials()));
-  boost::shared_ptr<TopicPublishInfo> topicPublishInfo(weak_topicPublishInfo.lock());
-  if (topicPublishInfo)  //&& topicPublishInfo->ok())
-  {
-    MQMessageQueue mq = pSelector->select(topicPublishInfo->getMessageQueueList(), msg, pArg);
-    return sendKernelImpl(msg, mq, communicationMode, sendCallback);
-  }
-  THROW_MQEXCEPTION(MQClientException, "No route info for this topic", -1);
-}
-
-SendResult DefaultMQProducer::sendAutoRetrySelectImpl(MQMessage& msg,
-                                                      MessageQueueSelector* pSelector,
-                                                      void* pArg,
-                                                      int communicationMode,
-                                                      SendCallback* pSendCallback,
-                                                      int autoRetryTimes,
-                                                      bool bActiveMQ) {
-  Validators::checkMessage(msg, getMaxMessageSize());
-
-  MQMessageQueue lastmq;
-  MQMessageQueue mq;
-  int mq_index = 0;
-  for (int times = 1; times <= autoRetryTimes + 1; times++) {
-    boost::weak_ptr<TopicPublishInfo> weak_topicPublishInfo(
-        getFactory()->tryToFindTopicPublishInfo(msg.getTopic(), getSessionCredentials()));
-    boost::shared_ptr<TopicPublishInfo> topicPublishInfo(weak_topicPublishInfo.lock());
-    if (topicPublishInfo) {
-      SendResult sendResult;
-      if (times == 1) {
-        // always send to selected MQ firstly, evenif bActiveMQ was setted to true
-        mq = pSelector->select(topicPublishInfo->getMessageQueueList(), msg, pArg);
-        lastmq = mq;
-      } else {
-        LOG_INFO("sendAutoRetrySelectImpl with times:%d", times);
-        std::vector<MQMessageQueue> mqs(topicPublishInfo->getMessageQueueList());
-        for (size_t i = 0; i < mqs.size(); i++) {
-          if (mqs[i] == lastmq)
-            mq_index = i;
-        }
-        if (bActiveMQ)
-          mq = topicPublishInfo->selectOneActiveMessageQueue(lastmq, mq_index);
-        else
-          mq = topicPublishInfo->selectOneMessageQueue(lastmq, mq_index);
-        lastmq = mq;
-        if (mq.getQueueId() == -1) {
-          // THROW_MQEXCEPTION(MQClientException, "the MQMessageQueue is
-          // invalide", -1);
-          continue;
-        }
-      }
-
-      try {
-        LOG_DEBUG("send to broker:%s", mq.toString().c_str());
-        sendResult = sendKernelImpl(msg, mq, communicationMode, pSendCallback);
-        switch (communicationMode) {
-          case ComMode_ASYNC:
-            return sendResult;
-          case ComMode_ONEWAY:
-            return sendResult;
-          case ComMode_SYNC:
-            if (sendResult.getSendStatus() != SEND_OK) {
-              if (bActiveMQ) {
-                topicPublishInfo->updateNonServiceMessageQueue(mq, getSendMsgTimeout());
-              }
-              continue;
-            }
-            return sendResult;
-          default:
-            break;
-        }
-      } catch (...) {
-        LOG_ERROR("send failed of times:%d,mq:%s", times, mq.toString().c_str());
-        if (bActiveMQ) {
-          topicPublishInfo->updateNonServiceMessageQueue(mq, getSendMsgTimeout());
-        }
-        continue;
-      }
-    }  // end of for
-    LOG_WARN("Retry many times, still failed");
-  }
-  THROW_MQEXCEPTION(MQClientException, "No route info of this topic, ", -1);
-}
-
-bool DefaultMQProducer::tryToCompressMessage(MQMessage& msg) {
-  int sysFlag = msg.getSysFlag();
-  if ((sysFlag & MessageSysFlag::CompressedFlag) == MessageSysFlag::CompressedFlag) {
-    return true;
-  }
-
-  string body = msg.getBody();
-  if ((int)body.length() >= getCompressMsgBodyOverHowmuch()) {
-    string outBody;
-    if (UtilAll::deflate(body, outBody, getCompressLevel())) {
-      msg.setBody(outBody);
-      msg.setSysFlag(sysFlag | MessageSysFlag::CompressedFlag);
-      return true;
-    }
-  }
-
-  return false;
+void DefaultMQProducer::setRetryTimes4Async(int times) {
+  impl->setRetryTimes4Async(times);
 }
 
-int DefaultMQProducer::getRetryTimes() const {
-  return m_retryTimes;
+int DefaultMQProducer::getRetryTimes4Async() const {
+  return impl->getRetryTimes4Async();
 }
 
-void DefaultMQProducer::setRetryTimes(int times) {
-  if (times <= 0) {
-    LOG_WARN("set retry times illegal, use default value:5");
-    return;
-  }
+void DefaultMQProducer::setLogLevel(elogLevel inputLevel) {
+  impl->setLogLevel(inputLevel);
+}
 
-  if (times > 15) {
-    LOG_WARN("set retry times illegal, use max value:15");
-    m_retryTimes = 15;
-    return;
-  }
-  LOG_WARN("set retry times to:%d", times);
-  m_retryTimes = times;
+elogLevel DefaultMQProducer::getLogLevel() {
+  return impl->getLogLevel();
+}
+void DefaultMQProducer::setLogFileSizeAndNum(int fileNum, long perFileSize) {
+  impl->setLogFileSizeAndNum(fileNum, perFileSize);
 }
 
-int DefaultMQProducer::getRetryTimes4Async() const {
-  return m_retryTimes4Async;
+void DefaultMQProducer::setTcpTransportPullThreadNum(int num) {
+  impl->setTcpTransportPullThreadNum(num);
+}
+const int DefaultMQProducer::getTcpTransportPullThreadNum() const {
+  return impl->getTcpTransportPullThreadNum();
 }
 
-void DefaultMQProducer::setRetryTimes4Async(int times) {
-  if (times <= 0) {
-    LOG_WARN("set retry times illegal, use default value:1");
-    m_retryTimes4Async = 1;
-    return;
-  }
-
-  if (times > 15) {
-    LOG_WARN("set retry times illegal, use max value:15");
-    m_retryTimes4Async = 15;
-    return;
-  }
-  LOG_INFO("set retry times to:%d", times);
-  m_retryTimes4Async = times;
-}
-
-// we should deal with name space before producer start.
-bool DefaultMQProducer::dealWithNameSpace() {
-  string ns = getNameSpace();
-  if (ns.empty()) {
-    string nsAddr = getNamesrvAddr();
-    if (!NameSpaceUtil::checkNameSpaceExistInNameServer(nsAddr)) {
-      return true;
-    }
-    ns = NameSpaceUtil::getNameSpaceFromNsURL(nsAddr);
-    // reset namespace
-    setNameSpace(ns);
-  }
-  // reset group name
-  if (!NameSpaceUtil::hasNameSpace(getGroupName(), ns)) {
-    string fullGID = NameSpaceUtil::withNameSpace(getGroupName(), ns);
-    setGroupName(fullGID);
-  }
-  return true;
-}
-//<!***************************************************************************
-}  // namespace rocketmq
+void DefaultMQProducer::setTcpTransportConnectTimeout(uint64_t timeout) {
+  impl->setTcpTransportConnectTimeout(timeout);
+}
+const uint64_t DefaultMQProducer::getTcpTransportConnectTimeout() const {
+  return impl->getTcpTransportConnectTimeout();
+}
+void DefaultMQProducer::setTcpTransportTryLockTimeout(uint64_t timeout) {
+  impl->setTcpTransportTryLockTimeout(timeout);
+}
+const uint64_t DefaultMQProducer::getTcpTransportTryLockTimeout() const {
+  return impl->getTcpTransportTryLockTimeout();
+}
+
+void DefaultMQProducer::setUnitName(std::string unitName) {
+  impl->setUnitName(unitName);
+}
+const std::string& DefaultMQProducer::getUnitName() const {
+  return impl->getUnitName();
+}
+
+SendResult DefaultMQProducer::send(MQMessage& msg, bool bSelectActiveBroker) {
+  return impl->send(msg, bSelectActiveBroker);
+}
+
+SendResult DefaultMQProducer::send(MQMessage& msg, const MQMessageQueue& mq) {
+  return impl->send(msg, mq);
+}
+
+SendResult DefaultMQProducer::send(MQMessage& msg, MessageQueueSelector* selector, void* arg) {
+  return impl->send(msg, selector, arg);
+}
+
+SendResult DefaultMQProducer::send(MQMessage& msg,
+                                   MessageQueueSelector* selector,
+                                   void* arg,
+                                   int autoRetryTimes,
+                                   bool bActiveBroker) {
+  return impl->send(msg, selector, arg, autoRetryTimes, bActiveBroker);
+}
+
+SendResult DefaultMQProducer::send(std::vector<MQMessage>& msgs) {
+  return impl->send(msgs);
+}
+
+SendResult DefaultMQProducer::send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq) {
+  return impl->send(msgs, mq);
+}
+
+void DefaultMQProducer::send(MQMessage& msg, SendCallback* pSendCallback, bool bSelectActiveBroker) {
+  impl->send(msg, pSendCallback, bSelectActiveBroker);
+}
+
+void DefaultMQProducer::send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* pSendCallback) {
+  impl->send(msg, mq, pSendCallback);
+}
+
+void DefaultMQProducer::send(MQMessage& msg, MessageQueueSelector* selector, void* arg, SendCallback* pSendCallback) {
+  impl->send(msg, selector, arg, pSendCallback);
+}
+
+void DefaultMQProducer::sendOneway(MQMessage& msg, bool bSelectActiveBroker) {
+  impl->sendOneway(msg, bSelectActiveBroker);
+}
+
+void DefaultMQProducer::sendOneway(MQMessage& msg, const MQMessageQueue& mq) {
+  impl->sendOneway(msg, mq);
+}
+
+void DefaultMQProducer::sendOneway(MQMessage& msg, MessageQueueSelector* selector, void* arg) {
+  impl->sendOneway(msg, selector, arg);
+}
+
+}  // namespace rocketmq
\ No newline at end of file
diff --git a/src/producer/DefaultMQProducer.cpp b/src/producer/DefaultMQProducerImpl.cpp
similarity index 80%
copy from src/producer/DefaultMQProducer.cpp
copy to src/producer/DefaultMQProducerImpl.cpp
index ee81a7b..aff238b 100644
--- a/src/producer/DefaultMQProducer.cpp
+++ b/src/producer/DefaultMQProducerImpl.cpp
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-#include "DefaultMQProducer.h"
+#include "DefaultMQProducerImpl.h"
 
 #include <assert.h>
 #include <typeindex>
@@ -39,7 +39,7 @@
 namespace rocketmq {
 
 //<!************************************************************************
-DefaultMQProducer::DefaultMQProducer(const string& groupname)
+DefaultMQProducerImpl::DefaultMQProducerImpl(const string& groupname)
     : m_sendMsgTimeout(3000),
       m_compressMsgBodyOverHowmuch(4 * 1024),
       m_maxMessageSize(1024 * 128),
@@ -52,9 +52,9 @@ DefaultMQProducer::DefaultMQProducer(const string& groupname)
   setGroupName(gname);
 }
 
-DefaultMQProducer::~DefaultMQProducer() {}
+DefaultMQProducerImpl::~DefaultMQProducerImpl() {}
 
-void DefaultMQProducer::start() {
+void DefaultMQProducerImpl::start() {
 #ifndef WIN32
   /* Ignore the SIGPIPE */
   struct sigaction sa;
@@ -68,8 +68,8 @@ void DefaultMQProducer::start() {
   switch (m_serviceState) {
     case CREATE_JUST: {
       m_serviceState = START_FAILED;
-      MQClient::start();
-      LOG_INFO("DefaultMQProducer:%s start", m_GroupName.c_str());
+      DefaultMQClient::start();
+      LOG_INFO("DefaultMQProducerImpl:%s start", m_GroupName.c_str());
 
       bool registerOK = getFactory()->registerProducer(this);
       if (!registerOK) {
@@ -93,10 +93,10 @@ void DefaultMQProducer::start() {
   }
 }
 
-void DefaultMQProducer::shutdown() {
+void DefaultMQProducerImpl::shutdown() {
   switch (m_serviceState) {
     case RUNNING: {
-      LOG_INFO("DefaultMQProducer shutdown");
+      LOG_INFO("DefaultMQProducerImpl shutdown");
       getFactory()->unregisterProducer(this);
       getFactory()->shutdown();
       m_serviceState = SHUTDOWN_ALREADY;
@@ -110,7 +110,7 @@ void DefaultMQProducer::shutdown() {
   }
 }
 
-SendResult DefaultMQProducer::send(MQMessage& msg, bool bSelectActiveBroker) {
+SendResult DefaultMQProducerImpl::send(MQMessage& msg, bool bSelectActiveBroker) {
   Validators::checkMessage(msg, getMaxMessageSize());
   if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
     MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -124,7 +124,7 @@ SendResult DefaultMQProducer::send(MQMessage& msg, bool bSelectActiveBroker) {
   return SendResult();
 }
 
-void DefaultMQProducer::send(MQMessage& msg, SendCallback* pSendCallback, bool bSelectActiveBroker) {
+void DefaultMQProducerImpl::send(MQMessage& msg, SendCallback* pSendCallback, bool bSelectActiveBroker) {
   Validators::checkMessage(msg, getMaxMessageSize());
   if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
     MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -137,7 +137,7 @@ void DefaultMQProducer::send(MQMessage& msg, SendCallback* pSendCallback, bool b
   }
 }
 
-SendResult DefaultMQProducer::send(std::vector<MQMessage>& msgs) {
+SendResult DefaultMQProducerImpl::send(std::vector<MQMessage>& msgs) {
   SendResult result;
   try {
     BatchMessage batchMessage = buildBatchMessage(msgs);
@@ -149,7 +149,7 @@ SendResult DefaultMQProducer::send(std::vector<MQMessage>& msgs) {
   return result;
 }
 
-SendResult DefaultMQProducer::send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq) {
+SendResult DefaultMQProducerImpl::send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq) {
   SendResult result;
   try {
     BatchMessage batchMessage = buildBatchMessage(msgs);
@@ -161,7 +161,7 @@ SendResult DefaultMQProducer::send(std::vector<MQMessage>& msgs, const MQMessage
   return result;
 }
 
-BatchMessage DefaultMQProducer::buildBatchMessage(std::vector<MQMessage>& msgs) {
+BatchMessage DefaultMQProducerImpl::buildBatchMessage(std::vector<MQMessage>& msgs) {
   if (msgs.size() < 1) {
     THROW_MQEXCEPTION(MQClientException, "msgs need one message at least", -1);
   }
@@ -200,7 +200,7 @@ BatchMessage DefaultMQProducer::buildBatchMessage(std::vector<MQMessage>& msgs)
   return batchMessage;
 }
 
-SendResult DefaultMQProducer::send(MQMessage& msg, const MQMessageQueue& mq) {
+SendResult DefaultMQProducerImpl::send(MQMessage& msg, const MQMessageQueue& mq) {
   Validators::checkMessage(msg, getMaxMessageSize());
   if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
     MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -217,7 +217,7 @@ SendResult DefaultMQProducer::send(MQMessage& msg, const MQMessageQueue& mq) {
   return SendResult();
 }
 
-void DefaultMQProducer::send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* pSendCallback) {
+void DefaultMQProducerImpl::send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* pSendCallback) {
   Validators::checkMessage(msg, getMaxMessageSize());
   if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
     MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -233,7 +233,7 @@ void DefaultMQProducer::send(MQMessage& msg, const MQMessageQueue& mq, SendCallb
   }
 }
 
-void DefaultMQProducer::sendOneway(MQMessage& msg, bool bSelectActiveBroker) {
+void DefaultMQProducerImpl::sendOneway(MQMessage& msg, bool bSelectActiveBroker) {
   Validators::checkMessage(msg, getMaxMessageSize());
   if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
     MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -246,7 +246,7 @@ void DefaultMQProducer::sendOneway(MQMessage& msg, bool bSelectActiveBroker) {
   }
 }
 
-void DefaultMQProducer::sendOneway(MQMessage& msg, const MQMessageQueue& mq) {
+void DefaultMQProducerImpl::sendOneway(MQMessage& msg, const MQMessageQueue& mq) {
   Validators::checkMessage(msg, getMaxMessageSize());
   if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
     MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -262,7 +262,7 @@ void DefaultMQProducer::sendOneway(MQMessage& msg, const MQMessageQueue& mq) {
   }
 }
 
-SendResult DefaultMQProducer::send(MQMessage& msg, MessageQueueSelector* pSelector, void* arg) {
+SendResult DefaultMQProducerImpl::send(MQMessage& msg, MessageQueueSelector* pSelector, void* arg) {
   try {
     if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
       MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -275,11 +275,11 @@ SendResult DefaultMQProducer::send(MQMessage& msg, MessageQueueSelector* pSelect
   return SendResult();
 }
 
-SendResult DefaultMQProducer::send(MQMessage& msg,
-                                   MessageQueueSelector* pSelector,
-                                   void* arg,
-                                   int autoRetryTimes,
-                                   bool bActiveBroker) {
+SendResult DefaultMQProducerImpl::send(MQMessage& msg,
+                                       MessageQueueSelector* pSelector,
+                                       void* arg,
+                                       int autoRetryTimes,
+                                       bool bActiveBroker) {
   try {
     if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
       MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -292,7 +292,10 @@ SendResult DefaultMQProducer::send(MQMessage& msg,
   return SendResult();
 }
 
-void DefaultMQProducer::send(MQMessage& msg, MessageQueueSelector* pSelector, void* arg, SendCallback* pSendCallback) {
+void DefaultMQProducerImpl::send(MQMessage& msg,
+                                 MessageQueueSelector* pSelector,
+                                 void* arg,
+                                 SendCallback* pSendCallback) {
   try {
     if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
       MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -304,7 +307,7 @@ void DefaultMQProducer::send(MQMessage& msg, MessageQueueSelector* pSelector, vo
   }
 }
 
-void DefaultMQProducer::sendOneway(MQMessage& msg, MessageQueueSelector* pSelector, void* arg) {
+void DefaultMQProducerImpl::sendOneway(MQMessage& msg, MessageQueueSelector* pSelector, void* arg) {
   try {
     if (!NameSpaceUtil::hasNameSpace(msg.getTopic(), getNameSpace())) {
       MessageAccessor::withNameSpace(msg, getNameSpace());
@@ -316,45 +319,45 @@ void DefaultMQProducer::sendOneway(MQMessage& msg, MessageQueueSelector* pSelect
   }
 }
 
-int DefaultMQProducer::getSendMsgTimeout() const {
+int DefaultMQProducerImpl::getSendMsgTimeout() const {
   return m_sendMsgTimeout;
 }
 
-void DefaultMQProducer::setSendMsgTimeout(int sendMsgTimeout) {
+void DefaultMQProducerImpl::setSendMsgTimeout(int sendMsgTimeout) {
   m_sendMsgTimeout = sendMsgTimeout;
 }
 
-int DefaultMQProducer::getCompressMsgBodyOverHowmuch() const {
+int DefaultMQProducerImpl::getCompressMsgBodyOverHowmuch() const {
   return m_compressMsgBodyOverHowmuch;
 }
 
-void DefaultMQProducer::setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
+void DefaultMQProducerImpl::setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
   m_compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
 }
 
-int DefaultMQProducer::getMaxMessageSize() const {
+int DefaultMQProducerImpl::getMaxMessageSize() const {
   return m_maxMessageSize;
 }
 
-void DefaultMQProducer::setMaxMessageSize(int maxMessageSize) {
+void DefaultMQProducerImpl::setMaxMessageSize(int maxMessageSize) {
   m_maxMessageSize = maxMessageSize;
 }
 
-int DefaultMQProducer::getCompressLevel() const {
+int DefaultMQProducerImpl::getCompressLevel() const {
   return m_compressLevel;
 }
 
-void DefaultMQProducer::setCompressLevel(int compressLevel) {
+void DefaultMQProducerImpl::setCompressLevel(int compressLevel) {
   assert((compressLevel >= 0 && compressLevel <= 9) || compressLevel == -1);
 
   m_compressLevel = compressLevel;
 }
 
 //<!************************************************************************
-SendResult DefaultMQProducer::sendDefaultImpl(MQMessage& msg,
-                                              int communicationMode,
-                                              SendCallback* pSendCallback,
-                                              bool bActiveMQ) {
+SendResult DefaultMQProducerImpl::sendDefaultImpl(MQMessage& msg,
+                                                  int communicationMode,
+                                                  SendCallback* pSendCallback,
+                                                  bool bActiveMQ) {
   MQMessageQueue lastmq;
   int mq_index = 0;
   for (int times = 1; times <= m_retryTimes; times++) {
@@ -415,10 +418,10 @@ SendResult DefaultMQProducer::sendDefaultImpl(MQMessage& msg,
   THROW_MQEXCEPTION(MQClientException, info, -1);
 }
 
-SendResult DefaultMQProducer::sendKernelImpl(MQMessage& msg,
-                                             const MQMessageQueue& mq,
-                                             int communicationMode,
-                                             SendCallback* sendCallback) {
+SendResult DefaultMQProducerImpl::sendKernelImpl(MQMessage& msg,
+                                                 const MQMessageQueue& mq,
+                                                 int communicationMode,
+                                                 SendCallback* sendCallback) {
   string brokerAddr = getFactory()->findBrokerAddressInPublish(mq.getBrokerName());
 
   if (brokerAddr.empty()) {
@@ -463,11 +466,11 @@ SendResult DefaultMQProducer::sendKernelImpl(MQMessage& msg,
   THROW_MQEXCEPTION(MQClientException, "The broker[" + mq.getBrokerName() + "] not exist", -1);
 }
 
-SendResult DefaultMQProducer::sendSelectImpl(MQMessage& msg,
-                                             MessageQueueSelector* pSelector,
-                                             void* pArg,
-                                             int communicationMode,
-                                             SendCallback* sendCallback) {
+SendResult DefaultMQProducerImpl::sendSelectImpl(MQMessage& msg,
+                                                 MessageQueueSelector* pSelector,
+                                                 void* pArg,
+                                                 int communicationMode,
+                                                 SendCallback* sendCallback) {
   Validators::checkMessage(msg, getMaxMessageSize());
 
   boost::weak_ptr<TopicPublishInfo> weak_topicPublishInfo(
@@ -481,13 +484,13 @@ SendResult DefaultMQProducer::sendSelectImpl(MQMessage& msg,
   THROW_MQEXCEPTION(MQClientException, "No route info for this topic", -1);
 }
 
-SendResult DefaultMQProducer::sendAutoRetrySelectImpl(MQMessage& msg,
-                                                      MessageQueueSelector* pSelector,
-                                                      void* pArg,
-                                                      int communicationMode,
-                                                      SendCallback* pSendCallback,
-                                                      int autoRetryTimes,
-                                                      bool bActiveMQ) {
+SendResult DefaultMQProducerImpl::sendAutoRetrySelectImpl(MQMessage& msg,
+                                                          MessageQueueSelector* pSelector,
+                                                          void* pArg,
+                                                          int communicationMode,
+                                                          SendCallback* pSendCallback,
+                                                          int autoRetryTimes,
+                                                          bool bActiveMQ) {
   Validators::checkMessage(msg, getMaxMessageSize());
 
   MQMessageQueue lastmq;
@@ -554,7 +557,7 @@ SendResult DefaultMQProducer::sendAutoRetrySelectImpl(MQMessage& msg,
   THROW_MQEXCEPTION(MQClientException, "No route info of this topic, ", -1);
 }
 
-bool DefaultMQProducer::tryToCompressMessage(MQMessage& msg) {
+bool DefaultMQProducerImpl::tryToCompressMessage(MQMessage& msg) {
   int sysFlag = msg.getSysFlag();
   if ((sysFlag & MessageSysFlag::CompressedFlag) == MessageSysFlag::CompressedFlag) {
     return true;
@@ -573,11 +576,11 @@ bool DefaultMQProducer::tryToCompressMessage(MQMessage& msg) {
   return false;
 }
 
-int DefaultMQProducer::getRetryTimes() const {
+int DefaultMQProducerImpl::getRetryTimes() const {
   return m_retryTimes;
 }
 
-void DefaultMQProducer::setRetryTimes(int times) {
+void DefaultMQProducerImpl::setRetryTimes(int times) {
   if (times <= 0) {
     LOG_WARN("set retry times illegal, use default value:5");
     return;
@@ -592,11 +595,11 @@ void DefaultMQProducer::setRetryTimes(int times) {
   m_retryTimes = times;
 }
 
-int DefaultMQProducer::getRetryTimes4Async() const {
+int DefaultMQProducerImpl::getRetryTimes4Async() const {
   return m_retryTimes4Async;
 }
 
-void DefaultMQProducer::setRetryTimes4Async(int times) {
+void DefaultMQProducerImpl::setRetryTimes4Async(int times) {
   if (times <= 0) {
     LOG_WARN("set retry times illegal, use default value:1");
     m_retryTimes4Async = 1;
@@ -613,7 +616,7 @@ void DefaultMQProducer::setRetryTimes4Async(int times) {
 }
 
 // we should deal with name space before producer start.
-bool DefaultMQProducer::dealWithNameSpace() {
+bool DefaultMQProducerImpl::dealWithNameSpace() {
   string ns = getNameSpace();
   if (ns.empty()) {
     string nsAddr = getNamesrvAddr();
diff --git a/include/DefaultMQProducer.h b/src/producer/DefaultMQProducerImpl.h
similarity index 93%
copy from include/DefaultMQProducer.h
copy to src/producer/DefaultMQProducerImpl.h
index 630e765..c4d2393 100644
--- a/include/DefaultMQProducer.h
+++ b/src/producer/DefaultMQProducerImpl.h
@@ -1,118 +1,118 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-#ifndef __DEFAULTMQPRODUCER_H__
-#define __DEFAULTMQPRODUCER_H__
-
-#include "BatchMessage.h"
-#include "MQMessageQueue.h"
-#include "MQProducer.h"
-#include "RocketMQClient.h"
-#include "SendResult.h"
-
-namespace rocketmq {
-//<!***************************************************************************
-class ROCKETMQCLIENT_API DefaultMQProducer : public MQProducer {
- public:
-  DefaultMQProducer(const std::string& groupname);
-  virtual ~DefaultMQProducer();
-
-  //<!begin mqadmin;
-  virtual void start();
-  virtual void shutdown();
-  //<!end mqadmin;
-
-  //<! begin MQProducer;
-  virtual SendResult send(MQMessage& msg, bool bSelectActiveBroker = false);
-  virtual SendResult send(MQMessage& msg, const MQMessageQueue& mq);
-  virtual SendResult send(MQMessage& msg, MessageQueueSelector* selector, void* arg);
-  virtual SendResult send(MQMessage& msg,
-                          MessageQueueSelector* selector,
-                          void* arg,
-                          int autoRetryTimes,
-                          bool bActiveBroker = false);
-  virtual SendResult send(std::vector<MQMessage>& msgs);
-  virtual SendResult send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq);
-  virtual void send(MQMessage& msg, SendCallback* pSendCallback, bool bSelectActiveBroker = false);
-  virtual void send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* pSendCallback);
-  virtual void send(MQMessage& msg, MessageQueueSelector* selector, void* arg, SendCallback* pSendCallback);
-  virtual void sendOneway(MQMessage& msg, bool bSelectActiveBroker = false);
-  virtual void sendOneway(MQMessage& msg, const MQMessageQueue& mq);
-  virtual void sendOneway(MQMessage& msg, MessageQueueSelector* selector, void* arg);
-  //<! end MQProducer;
-
-  // set and get timeout of per msg
-  int getSendMsgTimeout() const;
-  void setSendMsgTimeout(int sendMsgTimeout);
-
-  /*
-  *  if msgBody size is large than m_compressMsgBodyOverHowmuch
-      rocketmq cpp will compress msgBody according to compressLevel
-  */
-  int getCompressMsgBodyOverHowmuch() const;
-  void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch);
-  int getCompressLevel() const;
-  void setCompressLevel(int compressLevel);
-
-  // if msgbody size larger than maxMsgBodySize, exception will be throwed
-  int getMaxMessageSize() const;
-  void setMaxMessageSize(int maxMessageSize);
-
-  // set msg max retry times, default retry times is 5
-  int getRetryTimes() const;
-  void setRetryTimes(int times);
-
-  int getRetryTimes4Async() const;
-  void setRetryTimes4Async(int times);
-
- protected:
-  SendResult sendAutoRetrySelectImpl(MQMessage& msg,
-                                     MessageQueueSelector* pSelector,
-                                     void* pArg,
-                                     int communicationMode,
-                                     SendCallback* pSendCallback,
-                                     int retryTimes,
-                                     bool bActiveBroker = false);
-  SendResult sendSelectImpl(MQMessage& msg,
-                            MessageQueueSelector* pSelector,
-                            void* pArg,
-                            int communicationMode,
-                            SendCallback* sendCallback);
-  SendResult sendDefaultImpl(MQMessage& msg,
-                             int communicationMode,
-                             SendCallback* pSendCallback,
-                             bool bActiveBroker = false);
-  SendResult sendKernelImpl(MQMessage& msg,
-                            const MQMessageQueue& mq,
-                            int communicationMode,
-                            SendCallback* pSendCallback);
-  bool tryToCompressMessage(MQMessage& msg);
-  BatchMessage buildBatchMessage(std::vector<MQMessage>& msgs);
-  bool dealWithNameSpace();
-
- private:
-  int m_sendMsgTimeout;
-  int m_compressMsgBodyOverHowmuch;
-  int m_maxMessageSize;  //<! default:128K;
-  // bool m_retryAnotherBrokerWhenNotStoreOK;
-  int m_compressLevel;
-  int m_retryTimes;
-  int m_retryTimes4Async;
-};
-//<!***************************************************************************
-}  // namespace rocketmq
-#endif
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#ifndef __DEFAULTMQPRODUCERIMPL_H__
+#define __DEFAULTMQPRODUCERIMPL_H__
+
+#include "BatchMessage.h"
+#include "MQMessageQueue.h"
+#include "MQProducer.h"
+#include "RocketMQClient.h"
+#include "SendResult.h"
+
+namespace rocketmq {
+//<!***************************************************************************
+class DefaultMQProducerImpl : public MQProducer {
+ public:
+  DefaultMQProducerImpl(const std::string& groupname);
+  virtual ~DefaultMQProducerImpl();
+
+  //<!begin mqadmin;
+  virtual void start();
+  virtual void shutdown();
+  //<!end mqadmin;
+
+  //<! begin MQProducer;
+  virtual SendResult send(MQMessage& msg, bool bSelectActiveBroker = false);
+  virtual SendResult send(MQMessage& msg, const MQMessageQueue& mq);
+  virtual SendResult send(MQMessage& msg, MessageQueueSelector* selector, void* arg);
+  virtual SendResult send(MQMessage& msg,
+                          MessageQueueSelector* selector,
+                          void* arg,
+                          int autoRetryTimes,
+                          bool bActiveBroker = false);
+  virtual SendResult send(std::vector<MQMessage>& msgs);
+  virtual SendResult send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq);
+  virtual void send(MQMessage& msg, SendCallback* pSendCallback, bool bSelectActiveBroker = false);
+  virtual void send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* pSendCallback);
+  virtual void send(MQMessage& msg, MessageQueueSelector* selector, void* arg, SendCallback* pSendCallback);
+  virtual void sendOneway(MQMessage& msg, bool bSelectActiveBroker = false);
+  virtual void sendOneway(MQMessage& msg, const MQMessageQueue& mq);
+  virtual void sendOneway(MQMessage& msg, MessageQueueSelector* selector, void* arg);
+  //<! end MQProducer;
+
+  // set and get timeout of per msg
+  int getSendMsgTimeout() const;
+  void setSendMsgTimeout(int sendMsgTimeout);
+
+  /*
+  *  if msgBody size is large than m_compressMsgBodyOverHowmuch
+      rocketmq cpp will compress msgBody according to compressLevel
+  */
+  int getCompressMsgBodyOverHowmuch() const;
+  void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch);
+  int getCompressLevel() const;
+  void setCompressLevel(int compressLevel);
+
+  // if msgbody size larger than maxMsgBodySize, exception will be throwed
+  int getMaxMessageSize() const;
+  void setMaxMessageSize(int maxMessageSize);
+
+  // set msg max retry times, default retry times is 5
+  int getRetryTimes() const;
+  void setRetryTimes(int times);
+
+  int getRetryTimes4Async() const;
+  void setRetryTimes4Async(int times);
+
+ protected:
+  SendResult sendAutoRetrySelectImpl(MQMessage& msg,
+                                     MessageQueueSelector* pSelector,
+                                     void* pArg,
+                                     int communicationMode,
+                                     SendCallback* pSendCallback,
+                                     int retryTimes,
+                                     bool bActiveBroker = false);
+  SendResult sendSelectImpl(MQMessage& msg,
+                            MessageQueueSelector* pSelector,
+                            void* pArg,
+                            int communicationMode,
+                            SendCallback* sendCallback);
+  SendResult sendDefaultImpl(MQMessage& msg,
+                             int communicationMode,
+                             SendCallback* pSendCallback,
+                             bool bActiveBroker = false);
+  SendResult sendKernelImpl(MQMessage& msg,
+                            const MQMessageQueue& mq,
+                            int communicationMode,
+                            SendCallback* pSendCallback);
+  bool tryToCompressMessage(MQMessage& msg);
+  BatchMessage buildBatchMessage(std::vector<MQMessage>& msgs);
+  bool dealWithNameSpace();
+
+ private:
+  int m_sendMsgTimeout;
+  int m_compressMsgBodyOverHowmuch;
+  int m_maxMessageSize;  //<! default:128K;
+  // bool m_retryAnotherBrokerWhenNotStoreOK;
+  int m_compressLevel;
+  int m_retryTimes;
+  int m_retryTimes4Async;
+};
+//<!***************************************************************************
+}  // namespace rocketmq
+#endif
diff --git a/src/producer/TransactionMQProducer.cpp b/src/producer/TransactionMQProducer.cpp
index fbd78c5..b10e279 100644
--- a/src/producer/TransactionMQProducer.cpp
+++ b/src/producer/TransactionMQProducer.cpp
@@ -1,135 +1,148 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 "TransactionMQProducer.h"
-#include <string>
-#include "CommandHeader.h"
-#include "Logging.h"
-#include "MQClientFactory.h"
-#include "MQDecoder.h"
-#include "MessageSysFlag.h"
-#include "TransactionListener.h"
-#include "TransactionSendResult.h"
-
-using namespace std;
+
+#include "TransactionMQProducerImpl.h"
+
 namespace rocketmq {
 
-void TransactionMQProducer::initTransactionEnv() {
-  for (int i = 0; i < m_thread_num; ++i) {
-    m_threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &m_ioService));
-  }
+TransactionMQProducer::TransactionMQProducer(const std::string& groupName) {
+  impl = new TransactionMQProducerImpl(groupName);
 }
 
-void TransactionMQProducer::destroyTransactionEnv() {
-  m_ioService.stop();
-  m_threadpool.join_all();
+TransactionMQProducer::~TransactionMQProducer() {
+  delete impl;
+}
+void TransactionMQProducer::start() {
+  impl->start();
 }
 
-TransactionSendResult TransactionMQProducer::sendMessageInTransaction(MQMessage& msg, void* arg) {
-  if (!m_transactionListener) {
-    THROW_MQEXCEPTION(MQClientException, "transactionListener is null", -1);
-  }
-
-  SendResult sendResult;
-  msg.setProperty(MQMessage::PROPERTY_TRANSACTION_PREPARED, "true");
-  msg.setProperty(MQMessage::PROPERTY_PRODUCER_GROUP, getGroupName());
-  try {
-    sendResult = send(msg);
-  } catch (MQException& e) {
-    THROW_MQEXCEPTION(MQClientException, e.what(), -1);
-  }
-
-  LocalTransactionState localTransactionState = LocalTransactionState::UNKNOWN;
-  switch (sendResult.getSendStatus()) {
-    case SendStatus::SEND_OK:
-      try {
-        if (sendResult.getTransactionId() != "") {
-          msg.setProperty("__transactionId__", sendResult.getTransactionId());
-        }
-        string transactionId = msg.getProperty(MQMessage::PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
-        if (transactionId != "") {
-          msg.setTransactionId(transactionId);
-        }
-        LOG_DEBUG("sendMessageInTransaction, msgId:%s, transactionId:%s", sendResult.getMsgId().data(),
-                  transactionId.data());
-        localTransactionState = m_transactionListener->executeLocalTransaction(msg, arg);
-        if (localTransactionState != LocalTransactionState::COMMIT_MESSAGE) {
-          LOG_WARN("executeLocalTransaction ret not LocalTransactionState::commit, msg:%s", msg.toString().data());
-        }
-      } catch (MQException& e) {
-        THROW_MQEXCEPTION(MQClientException, e.what(), -1);
-      }
-      break;
-    case SendStatus::SEND_FLUSH_DISK_TIMEOUT:
-    case SendStatus::SEND_FLUSH_SLAVE_TIMEOUT:
-    case SendStatus::SEND_SLAVE_NOT_AVAILABLE:
-      localTransactionState = LocalTransactionState::ROLLBACK_MESSAGE;
-      LOG_WARN("sendMessageInTransaction, send not ok, rollback, result:%s", sendResult.toString().data());
-      break;
-    default:
-      break;
-  }
-
-  try {
-    endTransaction(sendResult, localTransactionState);
-  } catch (MQException& e) {
-    LOG_WARN("endTransaction exception:%s", e.what());
-  }
-
-  TransactionSendResult transactionSendResult(sendResult.getSendStatus(), sendResult.getMsgId(),
-                                              sendResult.getOffsetMsgId(), sendResult.getMessageQueue(),
-                                              sendResult.getQueueOffset());
-  transactionSendResult.setTransactionId(msg.getTransactionId());
-  transactionSendResult.setLocalTransactionState(localTransactionState);
-  return transactionSendResult;
-}
-
-void TransactionMQProducer::endTransaction(SendResult& sendResult, LocalTransactionState& localTransactionState) {
-  MQMessageId id;
-  if (sendResult.getOffsetMsgId() != "") {
-    id = MQDecoder::decodeMessageId(sendResult.getOffsetMsgId());
-  } else {
-    id = MQDecoder::decodeMessageId(sendResult.getMsgId());
-  }
-  string transId = sendResult.getTransactionId();
-
-  int commitOrRollback = MessageSysFlag::TransactionNotType;
-  switch (localTransactionState) {
-    case COMMIT_MESSAGE:
-      commitOrRollback = MessageSysFlag::TransactionCommitType;
-      break;
-    case ROLLBACK_MESSAGE:
-      commitOrRollback = MessageSysFlag::TransactionRollbackType;
-      break;
-    case UNKNOWN:
-      commitOrRollback = MessageSysFlag::TransactionNotType;
-      break;
-    default:
-      break;
-  }
-
-  bool fromTransCheck = false;
-  EndTransactionRequestHeader* requestHeader =
-      new EndTransactionRequestHeader(getGroupName(), sendResult.getQueueOffset(), id.getOffset(), commitOrRollback,
-                                      fromTransCheck, sendResult.getMsgId(), transId);
-  LOG_DEBUG("endTransaction: msg:%s", requestHeader->toString().data());
-  getFactory()->endTransactionOneway(sendResult.getMessageQueue(), requestHeader, getSessionCredentials());
+void TransactionMQProducer::shutdown() {
+  impl->shutdown();
+}
+
+// start mqclient set
+const std::string& TransactionMQProducer::getNamesrvAddr() const {
+  return impl->getNamesrvAddr();
+}
+
+void TransactionMQProducer::setNamesrvAddr(const std::string& namesrvAddr) {
+  impl->setNamesrvAddr(namesrvAddr);
+}
+
+const std::string& TransactionMQProducer::getNamesrvDomain() const {
+  return impl->getNamesrvDomain();
+}
+
+void TransactionMQProducer::setNamesrvDomain(const std::string& namesrvDomain) {
+  impl->setNamesrvDomain(namesrvDomain);
+}
+void TransactionMQProducer::setSessionCredentials(const std::string& accessKey,
+                                                  const std::string& secretKey,
+                                                  const std::string& accessChannel) {
+  impl->setSessionCredentials(accessKey, secretKey, accessChannel);
+}
+
+const SessionCredentials& TransactionMQProducer::getSessionCredentials() const {
+  return impl->getSessionCredentials();
+}
+const std::string& TransactionMQProducer::getInstanceName() const {
+  return impl->getInstanceName();
+}
+
+void TransactionMQProducer::setInstanceName(const std::string& instanceName) {
+  impl->setInstanceName(instanceName);
+}
+
+const std::string& TransactionMQProducer::getNameSpace() const {
+  return impl->getNameSpace();
+}
+
+void TransactionMQProducer::setNameSpace(const std::string& nameSpace) {
+  impl->setNameSpace(nameSpace);
+}
+const std::string& TransactionMQProducer::getGroupName() const {
+  return impl->getGroupName();
+}
+
+void TransactionMQProducer::setGroupName(const std::string& groupName) {
+  impl->setGroupName(groupName);
+}
+void TransactionMQProducer::setSendMsgTimeout(int sendMsgTimeout) {
+  impl->setSendMsgTimeout(sendMsgTimeout);
+}
+
+int TransactionMQProducer::getSendMsgTimeout() const {
+  return impl->getSendMsgTimeout();
+}
+void TransactionMQProducer::setTcpTransportPullThreadNum(int num) {
+  impl->setTcpTransportPullThreadNum(num);
+}
+const int TransactionMQProducer::getTcpTransportPullThreadNum() const {
+  return impl->getTcpTransportPullThreadNum();
+}
+
+void TransactionMQProducer::setTcpTransportConnectTimeout(uint64_t timeout) {
+  impl->setTcpTransportConnectTimeout(timeout);
+}
+const uint64_t TransactionMQProducer::getTcpTransportConnectTimeout() const {
+  return impl->getTcpTransportConnectTimeout();
+}
+void TransactionMQProducer::setTcpTransportTryLockTimeout(uint64_t timeout) {
+  impl->setTcpTransportTryLockTimeout(timeout);
+}
+const uint64_t TransactionMQProducer::getTcpTransportTryLockTimeout() const {
+  return impl->getTcpTransportTryLockTimeout();
+}
+int TransactionMQProducer::getCompressMsgBodyOverHowmuch() const {
+  return impl->getCompressMsgBodyOverHowmuch();
+}
+
+void TransactionMQProducer::setCompressMsgBodyOverHowmuch(int compressMsgBodyThreshold) {
+  impl->setCompressMsgBodyOverHowmuch(compressMsgBodyThreshold);
+}
+
+int TransactionMQProducer::getCompressLevel() const {
+  return impl->getCompressLevel();
+}
+
+void TransactionMQProducer::setCompressLevel(int compressLevel) {
+  impl->setCompressLevel(compressLevel);
+}
+
+void TransactionMQProducer::setMaxMessageSize(int maxMessageSize) {
+  impl->setMaxMessageSize(maxMessageSize);
+}
+
+int TransactionMQProducer::getMaxMessageSize() const {
+  return impl->getMaxMessageSize();
+}
+
+void TransactionMQProducer::setLogLevel(elogLevel inputLevel) {
+  impl->setLogLevel(inputLevel);
 }
 
+elogLevel TransactionMQProducer::getLogLevel() {
+  return impl->getLogLevel();
+}
+void TransactionMQProducer::setLogFileSizeAndNum(int fileNum, long perFileSize) {
+  impl->setLogFileSizeAndNum(fileNum, perFileSize);
+}
+
+void TransactionMQProducer::setUnitName(std::string unitName) {
+  impl->setUnitName(unitName);
+}
+const std::string& TransactionMQProducer::getUnitName() const {
+  return impl->getUnitName();
+}
+
+std::shared_ptr<TransactionListener> TransactionMQProducer::getTransactionListener() {
+  return impl->getTransactionListener();
+}
+void TransactionMQProducer::setTransactionListener(TransactionListener* listener) {
+  impl->setTransactionListener(listener);
+}
+TransactionSendResult TransactionMQProducer::sendMessageInTransaction(MQMessage& msg, void* arg) {
+  return impl->sendMessageInTransaction(msg, arg);
+}
 void TransactionMQProducer::checkTransactionState(const std::string& addr,
                                                   const MQMessageExt& message,
                                                   long tranStateTableOffset,
@@ -137,80 +150,6 @@ void TransactionMQProducer::checkTransactionState(const std::string& addr,
                                                   const std::string& msgId,
                                                   const std::string& transactionId,
                                                   const std::string& offsetMsgId) {
-  LOG_DEBUG("checkTransactionState: msgId:%s, transactionId:%s", msgId.data(), transactionId.data());
-  if (!m_transactionListener) {
-    LOG_WARN("checkTransactionState, transactionListener null");
-    THROW_MQEXCEPTION(MQClientException, "checkTransactionState, transactionListener null", -1);
-  }
-
-  m_ioService.post(boost::bind(&TransactionMQProducer::checkTransactionStateImpl, this, addr, message,
-                               tranStateTableOffset, commitLogOffset, msgId, transactionId, offsetMsgId));
-}
-
-void TransactionMQProducer::checkTransactionStateImpl(const std::string& addr,
-                                                      const MQMessageExt& message,
-                                                      long tranStateTableOffset,
-                                                      long commitLogOffset,
-                                                      const std::string& msgId,
-                                                      const std::string& transactionId,
-                                                      const std::string& offsetMsgId) {
-  LOG_DEBUG("checkTransactionStateImpl: msgId:%s, transactionId:%s", msgId.data(), transactionId.data());
-  LocalTransactionState localTransactionState = UNKNOWN;
-  try {
-    localTransactionState = m_transactionListener->checkLocalTransaction(message);
-  } catch (MQException& e) {
-    LOG_INFO("checkTransactionState, checkLocalTransaction exception: %s", e.what());
-  }
-
-  EndTransactionRequestHeader* endHeader = new EndTransactionRequestHeader();
-  endHeader->m_commitLogOffset = commitLogOffset;
-  endHeader->m_producerGroup = getGroupName();
-  endHeader->m_tranStateTableOffset = tranStateTableOffset;
-  endHeader->m_fromTransactionCheck = true;
-
-  string uniqueKey = transactionId;
-  if (transactionId.empty()) {
-    uniqueKey = message.getMsgId();
-  }
-
-  endHeader->m_msgId = uniqueKey;
-  endHeader->m_transactionId = transactionId;
-  switch (localTransactionState) {
-    case COMMIT_MESSAGE:
-      endHeader->m_commitOrRollback = MessageSysFlag::TransactionCommitType;
-      break;
-    case ROLLBACK_MESSAGE:
-      endHeader->m_commitOrRollback = MessageSysFlag::TransactionRollbackType;
-      LOG_WARN("when broker check, client rollback this transaction, %s", endHeader->toString().data());
-      break;
-    case UNKNOWN:
-      endHeader->m_commitOrRollback = MessageSysFlag::TransactionNotType;
-      LOG_WARN("when broker check, client does not know this transaction state, %s", endHeader->toString().data());
-      break;
-    default:
-      break;
-  }
-
-  LOG_INFO("checkTransactionState, endTransactionOneway: uniqueKey:%s, client state:%d, end header: %s",
-           uniqueKey.data(), localTransactionState, endHeader->toString().data());
-
-  string remark;
-  try {
-    getFactory()->getMQClientAPIImpl()->endTransactionOneway(addr, endHeader, remark, getSessionCredentials());
-  } catch (MQException& e) {
-    LOG_ERROR("endTransactionOneway exception:%s", e.what());
-    throw e;
-  }
-}
-
-void TransactionMQProducer::start() {
-  initTransactionEnv();
-  DefaultMQProducer::start();
+  impl->checkTransactionState(addr, message, tranStateTableOffset, commitLogOffset, msgId, transactionId, offsetMsgId);
 }
-
-void TransactionMQProducer::shutdown() {
-  DefaultMQProducer::shutdown();
-  destroyTransactionEnv();
-}
-
-}  // namespace rocketmq
+}  // namespace rocketmq
\ No newline at end of file
diff --git a/src/producer/TransactionMQProducer.cpp b/src/producer/TransactionMQProducerImpl.cpp
similarity index 85%
copy from src/producer/TransactionMQProducer.cpp
copy to src/producer/TransactionMQProducerImpl.cpp
index fbd78c5..849dd55 100644
--- a/src/producer/TransactionMQProducer.cpp
+++ b/src/producer/TransactionMQProducerImpl.cpp
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-#include "TransactionMQProducer.h"
+#include "TransactionMQProducerImpl.h"
 #include <string>
 #include "CommandHeader.h"
 #include "Logging.h"
@@ -28,18 +28,18 @@
 using namespace std;
 namespace rocketmq {
 
-void TransactionMQProducer::initTransactionEnv() {
+void TransactionMQProducerImpl::initTransactionEnv() {
   for (int i = 0; i < m_thread_num; ++i) {
     m_threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &m_ioService));
   }
 }
 
-void TransactionMQProducer::destroyTransactionEnv() {
+void TransactionMQProducerImpl::destroyTransactionEnv() {
   m_ioService.stop();
   m_threadpool.join_all();
 }
 
-TransactionSendResult TransactionMQProducer::sendMessageInTransaction(MQMessage& msg, void* arg) {
+TransactionSendResult TransactionMQProducerImpl::sendMessageInTransaction(MQMessage& msg, void* arg) {
   if (!m_transactionListener) {
     THROW_MQEXCEPTION(MQClientException, "transactionListener is null", -1);
   }
@@ -98,7 +98,7 @@ TransactionSendResult TransactionMQProducer::sendMessageInTransaction(MQMessage&
   return transactionSendResult;
 }
 
-void TransactionMQProducer::endTransaction(SendResult& sendResult, LocalTransactionState& localTransactionState) {
+void TransactionMQProducerImpl::endTransaction(SendResult& sendResult, LocalTransactionState& localTransactionState) {
   MQMessageId id;
   if (sendResult.getOffsetMsgId() != "") {
     id = MQDecoder::decodeMessageId(sendResult.getOffsetMsgId());
@@ -130,30 +130,30 @@ void TransactionMQProducer::endTransaction(SendResult& sendResult, LocalTransact
   getFactory()->endTransactionOneway(sendResult.getMessageQueue(), requestHeader, getSessionCredentials());
 }
 
-void TransactionMQProducer::checkTransactionState(const std::string& addr,
-                                                  const MQMessageExt& message,
-                                                  long tranStateTableOffset,
-                                                  long commitLogOffset,
-                                                  const std::string& msgId,
-                                                  const std::string& transactionId,
-                                                  const std::string& offsetMsgId) {
+void TransactionMQProducerImpl::checkTransactionState(const std::string& addr,
+                                                      const MQMessageExt& message,
+                                                      long tranStateTableOffset,
+                                                      long commitLogOffset,
+                                                      const std::string& msgId,
+                                                      const std::string& transactionId,
+                                                      const std::string& offsetMsgId) {
   LOG_DEBUG("checkTransactionState: msgId:%s, transactionId:%s", msgId.data(), transactionId.data());
   if (!m_transactionListener) {
     LOG_WARN("checkTransactionState, transactionListener null");
     THROW_MQEXCEPTION(MQClientException, "checkTransactionState, transactionListener null", -1);
   }
 
-  m_ioService.post(boost::bind(&TransactionMQProducer::checkTransactionStateImpl, this, addr, message,
+  m_ioService.post(boost::bind(&TransactionMQProducerImpl::checkTransactionStateImpl, this, addr, message,
                                tranStateTableOffset, commitLogOffset, msgId, transactionId, offsetMsgId));
 }
 
-void TransactionMQProducer::checkTransactionStateImpl(const std::string& addr,
-                                                      const MQMessageExt& message,
-                                                      long tranStateTableOffset,
-                                                      long commitLogOffset,
-                                                      const std::string& msgId,
-                                                      const std::string& transactionId,
-                                                      const std::string& offsetMsgId) {
+void TransactionMQProducerImpl::checkTransactionStateImpl(const std::string& addr,
+                                                          const MQMessageExt& message,
+                                                          long tranStateTableOffset,
+                                                          long commitLogOffset,
+                                                          const std::string& msgId,
+                                                          const std::string& transactionId,
+                                                          const std::string& offsetMsgId) {
   LOG_DEBUG("checkTransactionStateImpl: msgId:%s, transactionId:%s", msgId.data(), transactionId.data());
   LocalTransactionState localTransactionState = UNKNOWN;
   try {
@@ -203,13 +203,13 @@ void TransactionMQProducer::checkTransactionStateImpl(const std::string& addr,
   }
 }
 
-void TransactionMQProducer::start() {
+void TransactionMQProducerImpl::start() {
   initTransactionEnv();
-  DefaultMQProducer::start();
+  DefaultMQProducerImpl::start();
 }
 
-void TransactionMQProducer::shutdown() {
-  DefaultMQProducer::shutdown();
+void TransactionMQProducerImpl::shutdown() {
+  DefaultMQProducerImpl::shutdown();
   destroyTransactionEnv();
 }
 
diff --git a/include/TransactionMQProducer.h b/src/producer/TransactionMQProducerImpl.h
similarity index 87%
copy from include/TransactionMQProducer.h
copy to src/producer/TransactionMQProducerImpl.h
index fcd9a7c..603318b 100644
--- a/include/TransactionMQProducer.h
+++ b/src/producer/TransactionMQProducerImpl.h
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-#ifndef __TRANSACTIONMQPRODUCER_H__
-#define __TRANSACTIONMQPRODUCER_H__
+#ifndef __TRANSACTIONMQPRODUCERIMPL_H__
+#define __TRANSACTIONMQPRODUCERIMPL_H__
 
 #include <boost/asio.hpp>
 #include <boost/asio/io_service.hpp>
@@ -25,18 +25,18 @@
 #include <boost/weak_ptr.hpp>
 #include <memory>
 #include <string>
-#include "DefaultMQProducer.h"
+#include "DefaultMQProducerImpl.h"
 #include "MQMessageExt.h"
 #include "TransactionListener.h"
 #include "TransactionSendResult.h"
 
 namespace rocketmq {
 
-class ROCKETMQCLIENT_API TransactionMQProducer : public DefaultMQProducer {
+class TransactionMQProducerImpl : public DefaultMQProducerImpl {
  public:
-  TransactionMQProducer(const std::string& producerGroup)
-      : DefaultMQProducer(producerGroup), m_thread_num(1), m_ioServiceWork(m_ioService) {}
-  virtual ~TransactionMQProducer() {}
+  TransactionMQProducerImpl(const std::string& producerGroup)
+      : DefaultMQProducerImpl(producerGroup), m_thread_num(1), m_ioServiceWork(m_ioService) {}
+  virtual ~TransactionMQProducerImpl() {}
   void start();
   void shutdown();
   std::shared_ptr<TransactionListener> getTransactionListener() { return m_transactionListener; }