Migrate jms deve-1.1.0 branch to here

Project: 
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/commit/725026db
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/tree/725026db
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/diff/725026db

Branch: refs/heads/jms-dev-1.1.0
Commit: 725026dbe62a50b9edd4cf9fe9dec243368320a1
Parents: 8d01fb4
Author: yukon <[email protected]>
Authored: Wed Mar 15 22:07:47 2017 +0800
Committer: yukon <[email protected]>
Committed: Wed Mar 15 22:07:47 2017 +0800

----------------------------------------------------------------------
 .gitignore                                      |   5 -
 .travis.yml                                     |  43 --
 LICENSE                                         | 201 --------
 NOTICE                                          |   5 -
 README.md                                       |  32 --
 pom.xml                                         | 315 ------------
 rocketmq-jms/.gitignore                         |   5 +
 rocketmq-jms/.travis.yml                        |  43 ++
 rocketmq-jms/LICENSE                            | 201 ++++++++
 rocketmq-jms/NOTICE                             |   5 +
 rocketmq-jms/README.md                          |  32 ++
 rocketmq-jms/pom.xml                            | 315 ++++++++++++
 .../java/org/apache/rocketmq/jms/Constant.java  |  82 ++++
 .../rocketmq/jms/ConsumeMessageService.java     |  71 +++
 .../org/apache/rocketmq/jms/ConsumeModel.java   |  23 +
 .../rocketmq/jms/DeliverMessageService.java     | 275 +++++++++++
 .../org/apache/rocketmq/jms/MessageWrapper.java |  52 ++
 .../apache/rocketmq/jms/RocketMQConnection.java | 233 +++++++++
 .../rocketmq/jms/RocketMQConnectionFactory.java | 128 +++++
 .../jms/RocketMQConnectionMetaData.java         | 116 +++++
 .../apache/rocketmq/jms/RocketMQConsumer.java   | 152 ++++++
 .../apache/rocketmq/jms/RocketMQProducer.java   | 269 ++++++++++
 .../apache/rocketmq/jms/RocketMQSession.java    | 368 ++++++++++++++
 .../rocketmq/jms/RocketMQTopicSubscriber.java   |  44 ++
 .../rocketmq/jms/SendCompletionListener.java    |  43 ++
 .../apache/rocketmq/jms/admin/AdminFactory.java |  55 +++
 .../rocketmq/jms/destination/RocketMQQueue.java |  39 ++
 .../rocketmq/jms/destination/RocketMQTopic.java |  43 ++
 .../DuplicateSubscriptionException.java         |  31 ++
 .../jms/exception/JMSClientException.java       |  31 ++
 .../jms/exception/MessageExpiredException.java  |  31 ++
 .../UnsupportDeliveryModelException.java        |  27 +
 .../rocketmq/jms/hook/ReceiveMessageHook.java   |  44 ++
 .../rocketmq/jms/hook/SendMessageHook.java      | 104 ++++
 .../rocketmq/jms/msg/AbstractJMSMessage.java    | 400 +++++++++++++++
 .../rocketmq/jms/msg/JMSBytesMessage.java       | 491 +++++++++++++++++++
 .../apache/rocketmq/jms/msg/JMSMapMessage.java  | 229 +++++++++
 .../rocketmq/jms/msg/JMSObjectMessage.java      |  55 +++
 .../apache/rocketmq/jms/msg/JMSTextMessage.java |  67 +++
 .../jms/msg/convert/JMS2RMQMessageConvert.java  |  66 +++
 .../jms/msg/convert/RMQ2JMSMessageConvert.java  | 103 ++++
 .../rocketmq/jms/msg/enums/JMSHeaderEnum.java   |  44 ++
 .../jms/msg/enums/JMSMessageModelEnum.java      |  53 ++
 .../jms/msg/enums/JMSPropertiesEnum.java        |  26 +
 .../jms/msg/serialize/MapSerialize.java         |  43 ++
 .../jms/msg/serialize/ObjectSerialize.java      |  69 +++
 .../rocketmq/jms/msg/serialize/Serialize.java   |  27 +
 .../jms/msg/serialize/StringSerialize.java      |  49 ++
 .../apache/rocketmq/jms/support/JMSUtils.java   | 113 +++++
 .../rocketmq/jms/support/ObjectTypeCast.java    |  75 +++
 .../apache/rocketmq/jms/support/Prediction.java |  33 ++
 .../rocketmq/jms/support/PrimitiveTypeCast.java | 220 +++++++++
 .../rocketmq/jms/support/ProviderVersion.java   |  37 ++
 rocketmq-jms/src/main/resources/logback.xml     |  56 +++
 .../jms/RocketMQConnectionFactoryTest.java      |  36 ++
 .../jms/destination/RocketMQQueueTest.java      |  34 ++
 .../jms/destination/RocketMQTopicTest.java      |  35 ++
 .../jms/hook/ReceiveMessageHookTest.java        |  67 +++
 .../rocketmq/jms/hook/SendMessageHookTest.java  | 102 ++++
 .../jms/integration/source/AppConfig.java       |  59 +++
 .../jms/integration/source/Constant.java        |  39 ++
 .../jms/integration/source/RocketMQAdmin.java   |  94 ++++
 .../jms/integration/source/RocketMQServer.java  | 162 ++++++
 .../integration/source/SimpleTextListener.java  |  60 +++
 .../source/support/ConditionMatcher.java        |  23 +
 .../source/support/TimeLimitAssert.java         |  40 ++
 .../test/ConsumeAsynchronousTest.java           |  90 ++++
 .../test/ConsumeSynchronousTest.java            |  82 ++++
 .../integration/test/NonDurableConsumeTest.java | 132 +++++
 .../test/SharedDurableConsumeTest.java          | 120 +++++
 .../test/UnsharedDurableConsumeTest.java        | 127 +++++
 .../test/listener/SimpleTextListenerTest.java   |  60 +++
 .../rocketmq/jms/msg/JMSBytesMessageTest.java   | 106 ++++
 .../rocketmq/jms/msg/JMSMapMessageTest.java     |  70 +++
 .../rocketmq/jms/msg/JMSObjectMessageTest.java  |  73 +++
 .../rocketmq/jms/msg/JMSTextMessageTest.java    |  41 ++
 .../msg/convert/JMS2RMQMessageConvertTest.java  |  60 +++
 .../msg/convert/RMQ2JMSMessageConvertTest.java  |  65 +++
 .../jms/msg/enums/JMSMessageModelEnumTest.java  |  31 ++
 .../jms/msg/serialize/MapSerializeTest.java     |  42 ++
 .../jms/msg/serialize/ObjectSerializeTest.java  |  63 +++
 .../jms/msg/serialize/StringSerializeTest.java  |  36 ++
 .../rocketmq/jms/support/JMSUtilsTest.java      |  68 +++
 .../jms/support/ObjectTypeCastTest.java         |  52 ++
 .../rocketmq/jms/support/PredictionTest.java    |  45 ++
 .../jms/support/PrimitiveTypeCastTest.java      | 210 ++++++++
 rocketmq-jms/style/checkstyle-suppressions.xml  |  10 +
 rocketmq-jms/style/copyright/Apache.xml         |  24 +
 .../style/copyright/profiles_settings.xml       |  64 +++
 rocketmq-jms/style/rmq_checkstyle.xml           | 135 +++++
 rocketmq-jms/style/rmq_codeStyle.xml            | 157 ++++++
 .../java/org/apache/rocketmq/jms/Constant.java  |  82 ----
 .../rocketmq/jms/ConsumeMessageService.java     |  71 ---
 .../org/apache/rocketmq/jms/ConsumeModel.java   |  23 -
 .../rocketmq/jms/DeliverMessageService.java     | 275 -----------
 .../org/apache/rocketmq/jms/MessageWrapper.java |  52 --
 .../apache/rocketmq/jms/RocketMQConnection.java | 233 ---------
 .../rocketmq/jms/RocketMQConnectionFactory.java | 128 -----
 .../jms/RocketMQConnectionMetaData.java         | 116 -----
 .../apache/rocketmq/jms/RocketMQConsumer.java   | 152 ------
 .../apache/rocketmq/jms/RocketMQProducer.java   | 269 ----------
 .../apache/rocketmq/jms/RocketMQSession.java    | 368 --------------
 .../rocketmq/jms/RocketMQTopicSubscriber.java   |  44 --
 .../rocketmq/jms/SendCompletionListener.java    |  43 --
 .../apache/rocketmq/jms/admin/AdminFactory.java |  55 ---
 .../rocketmq/jms/destination/RocketMQQueue.java |  39 --
 .../rocketmq/jms/destination/RocketMQTopic.java |  43 --
 .../DuplicateSubscriptionException.java         |  31 --
 .../jms/exception/JMSClientException.java       |  31 --
 .../jms/exception/MessageExpiredException.java  |  31 --
 .../UnsupportDeliveryModelException.java        |  27 -
 .../rocketmq/jms/hook/ReceiveMessageHook.java   |  44 --
 .../rocketmq/jms/hook/SendMessageHook.java      | 104 ----
 .../rocketmq/jms/msg/AbstractJMSMessage.java    | 400 ---------------
 .../rocketmq/jms/msg/JMSBytesMessage.java       | 491 -------------------
 .../apache/rocketmq/jms/msg/JMSMapMessage.java  | 229 ---------
 .../rocketmq/jms/msg/JMSObjectMessage.java      |  55 ---
 .../apache/rocketmq/jms/msg/JMSTextMessage.java |  67 ---
 .../jms/msg/convert/JMS2RMQMessageConvert.java  |  66 ---
 .../jms/msg/convert/RMQ2JMSMessageConvert.java  | 103 ----
 .../rocketmq/jms/msg/enums/JMSHeaderEnum.java   |  44 --
 .../jms/msg/enums/JMSMessageModelEnum.java      |  53 --
 .../jms/msg/enums/JMSPropertiesEnum.java        |  26 -
 .../jms/msg/serialize/MapSerialize.java         |  43 --
 .../jms/msg/serialize/ObjectSerialize.java      |  69 ---
 .../rocketmq/jms/msg/serialize/Serialize.java   |  27 -
 .../jms/msg/serialize/StringSerialize.java      |  49 --
 .../apache/rocketmq/jms/support/JMSUtils.java   | 113 -----
 .../rocketmq/jms/support/ObjectTypeCast.java    |  75 ---
 .../apache/rocketmq/jms/support/Prediction.java |  33 --
 .../rocketmq/jms/support/PrimitiveTypeCast.java | 220 ---------
 .../rocketmq/jms/support/ProviderVersion.java   |  37 --
 src/main/resources/logback.xml                  |  56 ---
 .../jms/RocketMQConnectionFactoryTest.java      |  36 --
 .../jms/destination/RocketMQQueueTest.java      |  34 --
 .../jms/destination/RocketMQTopicTest.java      |  35 --
 .../jms/hook/ReceiveMessageHookTest.java        |  67 ---
 .../rocketmq/jms/hook/SendMessageHookTest.java  | 102 ----
 .../jms/integration/source/AppConfig.java       |  59 ---
 .../jms/integration/source/Constant.java        |  39 --
 .../jms/integration/source/RocketMQAdmin.java   |  94 ----
 .../jms/integration/source/RocketMQServer.java  | 162 ------
 .../integration/source/SimpleTextListener.java  |  60 ---
 .../source/support/ConditionMatcher.java        |  23 -
 .../source/support/TimeLimitAssert.java         |  40 --
 .../test/ConsumeAsynchronousTest.java           |  90 ----
 .../test/ConsumeSynchronousTest.java            |  82 ----
 .../integration/test/NonDurableConsumeTest.java | 132 -----
 .../test/SharedDurableConsumeTest.java          | 120 -----
 .../test/UnsharedDurableConsumeTest.java        | 127 -----
 .../test/listener/SimpleTextListenerTest.java   |  60 ---
 .../rocketmq/jms/msg/JMSBytesMessageTest.java   | 106 ----
 .../rocketmq/jms/msg/JMSMapMessageTest.java     |  70 ---
 .../rocketmq/jms/msg/JMSObjectMessageTest.java  |  73 ---
 .../rocketmq/jms/msg/JMSTextMessageTest.java    |  41 --
 .../msg/convert/JMS2RMQMessageConvertTest.java  |  60 ---
 .../msg/convert/RMQ2JMSMessageConvertTest.java  |  65 ---
 .../jms/msg/enums/JMSMessageModelEnumTest.java  |  31 --
 .../jms/msg/serialize/MapSerializeTest.java     |  42 --
 .../jms/msg/serialize/ObjectSerializeTest.java  |  63 ---
 .../jms/msg/serialize/StringSerializeTest.java  |  36 --
 .../rocketmq/jms/support/JMSUtilsTest.java      |  68 ---
 .../jms/support/ObjectTypeCastTest.java         |  52 --
 .../rocketmq/jms/support/PredictionTest.java    |  45 --
 .../jms/support/PrimitiveTypeCastTest.java      | 210 --------
 style/checkstyle-suppressions.xml               |  10 -
 style/copyright/Apache.xml                      |  24 -
 style/copyright/profiles_settings.xml           |  64 ---
 style/rmq_checkstyle.xml                        | 135 -----
 style/rmq_codeStyle.xml                         | 157 ------
 170 files changed, 7832 insertions(+), 7832 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 7dd589a..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.idea/
-*.iml
-target/
-*.ipr
-*.iws

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 292928e..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-notifications:
-  email:
-    recipients:
-      - [email protected]
-  on_success: change
-  on_failure: always
-
-language: java
-
-matrix:
-  include:
-  # On OSX, run with default JDK only.
-  # - os: osx
-  # On Linux, run with specific JDKs only.
-  # - os: linux
-  #  env: CUSTOM_JDK="oraclejdk8"
-  - os: linux
-    env: CUSTOM_JDK="oraclejdk7"
-  #- os: linux
-  #  env: CUSTOM_JDK="openjdk7"
-
-before_install:
-  - echo 'MAVEN_OPTS="$MAVEN_OPTS -Xmx1024m -XX:MaxPermSize=512m 
-XX:+BytecodeVerificationLocal"' >> ~/.mavenrc
-  - cat ~/.mavenrc
-  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export 
JAVA_HOME=$(/usr/libexec/java_home); fi
-  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then jdk_switcher use "$CUSTOM_JDK"; 
fi
-
-#os:
-#  - linux
-#  - osx
-#jdk:
-#  - oraclejdk8
-#  - oraclejdk7
-#  - openjdk7
-
-
-script:
-  - travis_retry mvn -B clean install findbugs:findbugs jacoco:report 
coveralls:report
-
-
-#after_success:
-#  - mvn clean install
-#  - mvn sonar:sonar

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 7f77f44..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (properties) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index fa71dc2..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache RocketMQ-JMS (incubating)
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
deleted file mode 100644
index d612224..0000000
--- a/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# RocketMQ-JMS  
-
-
-## Introduction
-RocketMQ-JMS is an implement of JMS specification,taking Apache RocketMQ as 
broker.
-Now we are on the way of supporting JMS 1.1 and JMS2.0 is our final target.   
-
-Java 7 should be used for building as JMS specification over 2.0 only support 
at least Java 7.
-
-## Support features
- 
- - Support basic features that producing and consuming messages smoothly.
- - Support mandatory JMS headers, built-in properties and user properties.
- - Support both point-to-point and publish/subscribe models.
- - Support both synchronous and asynchronous consume model.
- - Support unshared non-durable, unshared durable, shared non-durable, shared 
durable subscription.
- - Support features such as message order, AUTO_ACKNOWLEDGE.
- - Follow single-thread restriction of session.
- - Support Spring JMS 4 partially.
-  
-## Building
-````
-  cd rocketmq-jms
-  mvn clean install  
-  ````  
-  **run unit test:**  mvn test    
-  
-  **run integration test:**  mvn verify
-  
-## Guidelines
-
- Please see [Coding Guidelines 
Introduction](http://rocketmq.apache.org/docs/code-guidelines/)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 51a4ab5..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,315 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xmlns="http://maven.apache.org/POM/4.0.0";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>org.apache.rocketmq</groupId>
-    <artifactId>rocketmq-jms</artifactId>
-    <packaging>jar</packaging>
-    <version>1.0.0</version>
-
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.test.skip>false</maven.test.skip>
-        <maven.javadoc.skip>true</maven.javadoc.skip>
-        <maven.compiler.source>1.7</maven.compiler.source>
-        <maven.compiler.target>1.7</maven.compiler.target>
-        <surefire.version>2.19.1</surefire.version>
-        <rocketmq.version>4.0.0-incubating</rocketmq.version>
-        <spring.version>4.3.6.RELEASE</spring.version>
-    </properties>
-
-    <licenses>
-        <license>
-            <name>Apache License, Version 2.0</name>
-            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
-            <distribution>repo</distribution>
-        </license>
-    </licenses>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.rocketmq</groupId>
-            <artifactId>rocketmq-client</artifactId>
-            <version>${rocketmq.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.rocketmq</groupId>
-            <artifactId>rocketmq-tools</artifactId>
-            <version>${rocketmq.version}</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.rocketmq</groupId>
-                    <artifactId>rocketmq-store</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.rocketmq</groupId>
-                    <artifactId>rocketmq-srvutil</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>com.alibaba</groupId>
-                    <artifactId>fastjson</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>ch.qos.logback</groupId>
-                    <artifactId>logback-classic</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>ch.qos.logback</groupId>
-                    <artifactId>logback-core</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>javax.jms</groupId>
-            <artifactId>javax.jms-api</artifactId>
-            <version>2.0.1</version>
-        </dependency>
-        <!--test-->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.12</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-all</artifactId>
-            <version>1.3</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <version>2.7.12</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-jms</artifactId>
-            <version>${spring.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-test</artifactId>
-            <version>${spring.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.rocketmq</groupId>
-            <artifactId>rocketmq-namesrv</artifactId>
-            <version>${rocketmq.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.rocketmq</groupId>
-            <artifactId>rocketmq-broker</artifactId>
-            <version>${rocketmq.version}</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <finalName>rocketmq-jms-${project.version}</finalName>
-        <!--<resources>-->
-            <!--<resource>-->
-                <!--<directory>${project.basedir}</directory>-->
-                <!--<targetPath>META-INF</targetPath>-->
-                <!--<includes>-->
-                    <!--<include>LICENSE</include>-->
-                    <!--<include>NOTICE</include>-->
-                <!--</includes>-->
-            <!--</resource>-->
-        <!--</resources>-->
-        <plugins>
-            <plugin>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.5.1</version>
-                <configuration>
-                    <source>${maven.compiler.source}</source>
-                    <target>${maven.compiler.target}</target>
-                    <compilerVersion>${maven.compiler.source}</compilerVersion>
-                    <showDeprecation>true</showDeprecation>
-                    <showWarnings>true</showWarnings>
-                </configuration>
-            </plugin>
-            <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${surefire.version}</version>
-                <configuration>
-                    <excludes>
-                        <exclude>**/integration/**</exclude>
-                    </excludes>
-                    <forkCount>1</forkCount>
-                    <reuseForks>true</reuseForks>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-failsafe-plugin</artifactId>
-                <version>2.19.1</version>
-                <configuration>
-                    <forkCount>1</forkCount>
-                    <reuseForks>true</reuseForks>
-                    <includes>
-                        <include>**/integration/**</include>
-                    </includes>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>integration-test</goal>
-                            <goal>verify</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <exclude>**/logback.xml</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-            <plugin>
-                <artifactId>maven-source-plugin</artifactId>
-                <version>3.0.1</version>
-                <executions>
-                    <execution>
-                        <id>attach-sources</id>
-                        <goals>
-                            <goal>jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.10.4</version>
-                <configuration>
-                    <charset>UTF-8</charset>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>attach-javadocs</id>
-                        <goals>
-                            <goal>jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <version>2.17</version>
-                <executions>
-                    <execution>
-                        <id>verify</id>
-                        <phase>verify</phase>
-                        <configuration>
-                            
<configLocation>style/rmq_checkstyle.xml</configLocation>
-                            <encoding>UTF-8</encoding>
-                            <consoleOutput>true</consoleOutput>
-                            <failsOnError>true</failsOnError>
-                        </configuration>
-                        <goals>
-                            <goal>check</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.7.9</version>
-                <executions>
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                        <configuration>
-                            
<destFile>${project.build.directory}/jacoco.exec</destFile>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>default-prepare-agent-integration</id>
-                        <phase>pre-integration-test</phase>
-                        <goals>
-                            <goal>prepare-agent-integration</goal>
-                        </goals>
-                        <configuration>
-                            
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
-                            <propertyName>failsafeArgLine</propertyName>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>default-report</id>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                    <execution>
-                        <id>default-report-integration</id>
-                        <goals>
-                            <goal>report-integration</goal>
-                        </goals>
-                    </execution>
-                    <execution>
-                        <id>default-check</id>
-                        <goals>
-                            <goal>check</goal>
-                        </goals>
-                        <configuration>
-                            <rules>
-                                <!-- implementation is needed only for Maven 2 
-->
-                                <rule 
implementation="org.jacoco.maven.RuleConfiguration">
-                                    <element>BUNDLE</element>
-                                    <limits>
-                                        <!-- implementation is needed only for 
Maven 2 -->
-                                        <limit 
implementation="org.jacoco.report.check.Limit">
-                                            <counter>COMPLEXITY</counter>
-                                            <value>COVEREDRATIO</value>
-                                            <minimum>0.30</minimum>
-                                        </limit>
-                                    </limits>
-                                </rule>
-                            </rules>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.eluder.coveralls</groupId>
-                <artifactId>coveralls-maven-plugin</artifactId>
-                <version>4.3.0</version>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>findbugs-maven-plugin</artifactId>
-                <version>3.0.4</version>
-            </plugin>
-        </plugins>
-    </build>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/.gitignore
----------------------------------------------------------------------
diff --git a/rocketmq-jms/.gitignore b/rocketmq-jms/.gitignore
new file mode 100644
index 0000000..7dd589a
--- /dev/null
+++ b/rocketmq-jms/.gitignore
@@ -0,0 +1,5 @@
+.idea/
+*.iml
+target/
+*.ipr
+*.iws

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/.travis.yml
----------------------------------------------------------------------
diff --git a/rocketmq-jms/.travis.yml b/rocketmq-jms/.travis.yml
new file mode 100644
index 0000000..292928e
--- /dev/null
+++ b/rocketmq-jms/.travis.yml
@@ -0,0 +1,43 @@
+notifications:
+  email:
+    recipients:
+      - [email protected]
+  on_success: change
+  on_failure: always
+
+language: java
+
+matrix:
+  include:
+  # On OSX, run with default JDK only.
+  # - os: osx
+  # On Linux, run with specific JDKs only.
+  # - os: linux
+  #  env: CUSTOM_JDK="oraclejdk8"
+  - os: linux
+    env: CUSTOM_JDK="oraclejdk7"
+  #- os: linux
+  #  env: CUSTOM_JDK="openjdk7"
+
+before_install:
+  - echo 'MAVEN_OPTS="$MAVEN_OPTS -Xmx1024m -XX:MaxPermSize=512m 
-XX:+BytecodeVerificationLocal"' >> ~/.mavenrc
+  - cat ~/.mavenrc
+  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export 
JAVA_HOME=$(/usr/libexec/java_home); fi
+  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then jdk_switcher use "$CUSTOM_JDK"; 
fi
+
+#os:
+#  - linux
+#  - osx
+#jdk:
+#  - oraclejdk8
+#  - oraclejdk7
+#  - openjdk7
+
+
+script:
+  - travis_retry mvn -B clean install findbugs:findbugs jacoco:report 
coveralls:report
+
+
+#after_success:
+#  - mvn clean install
+#  - mvn sonar:sonar

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/LICENSE
----------------------------------------------------------------------
diff --git a/rocketmq-jms/LICENSE b/rocketmq-jms/LICENSE
new file mode 100644
index 0000000..7f77f44
--- /dev/null
+++ b/rocketmq-jms/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (properties) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/NOTICE
----------------------------------------------------------------------
diff --git a/rocketmq-jms/NOTICE b/rocketmq-jms/NOTICE
new file mode 100644
index 0000000..fa71dc2
--- /dev/null
+++ b/rocketmq-jms/NOTICE
@@ -0,0 +1,5 @@
+Apache RocketMQ-JMS (incubating)
+Copyright 2016-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/README.md
----------------------------------------------------------------------
diff --git a/rocketmq-jms/README.md b/rocketmq-jms/README.md
new file mode 100644
index 0000000..d612224
--- /dev/null
+++ b/rocketmq-jms/README.md
@@ -0,0 +1,32 @@
+# RocketMQ-JMS  
+
+
+## Introduction
+RocketMQ-JMS is an implement of JMS specification,taking Apache RocketMQ as 
broker.
+Now we are on the way of supporting JMS 1.1 and JMS2.0 is our final target.   
+
+Java 7 should be used for building as JMS specification over 2.0 only support 
at least Java 7.
+
+## Support features
+ 
+ - Support basic features that producing and consuming messages smoothly.
+ - Support mandatory JMS headers, built-in properties and user properties.
+ - Support both point-to-point and publish/subscribe models.
+ - Support both synchronous and asynchronous consume model.
+ - Support unshared non-durable, unshared durable, shared non-durable, shared 
durable subscription.
+ - Support features such as message order, AUTO_ACKNOWLEDGE.
+ - Follow single-thread restriction of session.
+ - Support Spring JMS 4 partially.
+  
+## Building
+````
+  cd rocketmq-jms
+  mvn clean install  
+  ````  
+  **run unit test:**  mvn test    
+  
+  **run integration test:**  mvn verify
+  
+## Guidelines
+
+ Please see [Coding Guidelines 
Introduction](http://rocketmq.apache.org/docs/code-guidelines/)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/pom.xml
----------------------------------------------------------------------
diff --git a/rocketmq-jms/pom.xml b/rocketmq-jms/pom.xml
new file mode 100644
index 0000000..51a4ab5
--- /dev/null
+++ b/rocketmq-jms/pom.xml
@@ -0,0 +1,315 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xmlns="http://maven.apache.org/POM/4.0.0";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.rocketmq</groupId>
+    <artifactId>rocketmq-jms</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0</version>
+
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.test.skip>false</maven.test.skip>
+        <maven.javadoc.skip>true</maven.javadoc.skip>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+        <surefire.version>2.19.1</surefire.version>
+        <rocketmq.version>4.0.0-incubating</rocketmq.version>
+        <spring.version>4.3.6.RELEASE</spring.version>
+    </properties>
+
+    <licenses>
+        <license>
+            <name>Apache License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-client</artifactId>
+            <version>${rocketmq.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-tools</artifactId>
+            <version>${rocketmq.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.rocketmq</groupId>
+                    <artifactId>rocketmq-store</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.rocketmq</groupId>
+                    <artifactId>rocketmq-srvutil</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.alibaba</groupId>
+                    <artifactId>fastjson</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-classic</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-core</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>javax.jms</groupId>
+            <artifactId>javax.jms-api</artifactId>
+            <version>2.0.1</version>
+        </dependency>
+        <!--test-->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-all</artifactId>
+            <version>1.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>2.7.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jms</artifactId>
+            <version>${spring.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <version>${spring.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-namesrv</artifactId>
+            <version>${rocketmq.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-broker</artifactId>
+            <version>${rocketmq.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>rocketmq-jms-${project.version}</finalName>
+        <!--<resources>-->
+            <!--<resource>-->
+                <!--<directory>${project.basedir}</directory>-->
+                <!--<targetPath>META-INF</targetPath>-->
+                <!--<includes>-->
+                    <!--<include>LICENSE</include>-->
+                    <!--<include>NOTICE</include>-->
+                <!--</includes>-->
+            <!--</resource>-->
+        <!--</resources>-->
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.5.1</version>
+                <configuration>
+                    <source>${maven.compiler.source}</source>
+                    <target>${maven.compiler.target}</target>
+                    <compilerVersion>${maven.compiler.source}</compilerVersion>
+                    <showDeprecation>true</showDeprecation>
+                    <showWarnings>true</showWarnings>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <configuration>
+                    <excludes>
+                        <exclude>**/integration/**</exclude>
+                    </excludes>
+                    <forkCount>1</forkCount>
+                    <reuseForks>true</reuseForks>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <version>2.19.1</version>
+                <configuration>
+                    <forkCount>1</forkCount>
+                    <reuseForks>true</reuseForks>
+                    <includes>
+                        <include>**/integration/**</include>
+                    </includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>**/logback.xml</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>3.0.1</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.10.4</version>
+                <configuration>
+                    <charset>UTF-8</charset>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>attach-javadocs</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <version>2.17</version>
+                <executions>
+                    <execution>
+                        <id>verify</id>
+                        <phase>verify</phase>
+                        <configuration>
+                            
<configLocation>style/rmq_checkstyle.xml</configLocation>
+                            <encoding>UTF-8</encoding>
+                            <consoleOutput>true</consoleOutput>
+                            <failsOnError>true</failsOnError>
+                        </configuration>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>0.7.9</version>
+                <executions>
+                    <execution>
+                        <id>default-prepare-agent</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                        <configuration>
+                            
<destFile>${project.build.directory}/jacoco.exec</destFile>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>default-prepare-agent-integration</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>prepare-agent-integration</goal>
+                        </goals>
+                        <configuration>
+                            
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
+                            <propertyName>failsafeArgLine</propertyName>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>default-report</id>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>default-report-integration</id>
+                        <goals>
+                            <goal>report-integration</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>default-check</id>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                        <configuration>
+                            <rules>
+                                <!-- implementation is needed only for Maven 2 
-->
+                                <rule 
implementation="org.jacoco.maven.RuleConfiguration">
+                                    <element>BUNDLE</element>
+                                    <limits>
+                                        <!-- implementation is needed only for 
Maven 2 -->
+                                        <limit 
implementation="org.jacoco.report.check.Limit">
+                                            <counter>COMPLEXITY</counter>
+                                            <value>COVEREDRATIO</value>
+                                            <minimum>0.30</minimum>
+                                        </limit>
+                                    </limits>
+                                </rule>
+                            </rules>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.eluder.coveralls</groupId>
+                <artifactId>coveralls-maven-plugin</artifactId>
+                <version>4.3.0</version>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <version>3.0.4</version>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/Constant.java
----------------------------------------------------------------------
diff --git a/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/Constant.java 
b/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/Constant.java
new file mode 100644
index 0000000..9519bea
--- /dev/null
+++ b/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/Constant.java
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+package org.apache.rocketmq.jms;
+
+public interface Constant {
+
+    String NO_MESSAGE_SELECTOR = "*";
+
+    boolean DEFAULT_NO_LOCAL = true;
+
+    boolean DEFAULT_DURABLE = false;
+
+    //-------------------------JMS defined properties 
constant----------------------------
+    /**
+     * The identity of the user sending the Send message
+     */
+    String JMS_XUSER_ID = "jmsXUserID";
+    /**
+     * The identity of the application Send sending the message
+     */
+    String JMS_XAPP_ID = "jmsXAppID";
+    /**
+     * The number of message delivery Receive attempts
+     */
+    String JMS_XDELIVERY_COUNT = "jmsXDeliveryCount";
+    /**
+     * The identity of the message group this message is part of
+     */
+    String JMS_XGROUP_ID = "jmsXGroupID";
+    /**
+     * The sequence number of this message within the group; the first message 
is 1, the second 2,...
+     */
+    String JMS_XGROUP_SEQ = "jmsXGroupSeq";
+    /**
+     * The transaction identifier of the Send transaction within which this 
message was produced
+     */
+    String JMS_XPRODUCER_TXID = "jmsXProducerTXID";
+    /**
+     * The transaction identifier of the Receive transaction within which this 
message was consumed
+     */
+    String JMS_XCONSUMER_TXID = "jmsXConsumerTXID";
+
+    /**
+     * The time JMS delivered the Receive message to the consumer
+     */
+    String JMS_XRCV_TIMESTAMP = "jmsXRcvTimestamp";
+    /**
+     * Assume there exists a message warehouse that contains a separate copy 
of each message sent to each consumer and
+     * that these copies exist from the time the original message was sent. 
Each copy’s state is one of: 1(waiting),
+     * 2(ready), 3(expired) or 4(retained) Since state is of no interest to 
producers and consumers it is not provided
+     * to either. It is only of relevance to messages looked up in a warehouse 
and JMS provides no API for this.
+     */
+    String JMS_XSTATE = "jmsXState";
+
+    //---------------------------JMS Headers' value 
constant---------------------------
+    /**
+     * Default time to live
+     */
+    long DEFAULT_TIME_TO_LIVE = 3 * 24 * 60 * 60 * 1000;
+
+    /**
+     * Default Jms Type
+     */
+    String DEFAULT_JMS_TYPE = "rocketmq";
+
+    String MESSAGE_ID_PREFIX = "ID:";
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/ConsumeMessageService.java
----------------------------------------------------------------------
diff --git 
a/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/ConsumeMessageService.java 
b/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/ConsumeMessageService.java
new file mode 100644
index 0000000..6187ac2
--- /dev/null
+++ 
b/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/ConsumeMessageService.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+package org.apache.rocketmq.jms;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.jms.JMSRuntimeException;
+import org.apache.rocketmq.common.ServiceThread;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConsumeMessageService extends ServiceThread {
+
+    private static final Logger log = 
LoggerFactory.getLogger(DeliverMessageService.class);
+    private static final AtomicLong COUNTER = new AtomicLong(0L);
+
+    private BlockingQueue<MessageWrapper> queue = new ArrayBlockingQueue(1000);
+    private RocketMQSession session;
+    private final long index = COUNTER.incrementAndGet();
+
+    public ConsumeMessageService(RocketMQSession session) {
+        this.session = session;
+    }
+
+    @Override public String getServiceName() {
+        return ConsumeMessageService.class.getSimpleName() + "-" + this.index;
+    }
+
+    @Override public void run() {
+        while (!this.isStopped()) {
+            try {
+                MessageWrapper wrapper = queue.take();
+                RocketMQConsumer consumer = wrapper.getConsumer();
+                consumer.getMessageListener().onMessage(wrapper.getMessage());
+                consumer.getDeliverMessageService().ack(wrapper.getMq(), 
wrapper.getOffset());
+            }
+            catch (Exception e) {
+                log.error(e.getMessage(), e);
+            }
+        }
+    }
+
+    public void put(MessageWrapper wrapper) {
+        try {
+            this.queue.put(wrapper);
+        }
+        catch (InterruptedException e) {
+            throw new JMSRuntimeException(e.getMessage());
+        }
+    }
+
+    public RocketMQSession getSession() {
+        return session;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/ConsumeModel.java
----------------------------------------------------------------------
diff --git 
a/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/ConsumeModel.java 
b/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/ConsumeModel.java
new file mode 100644
index 0000000..356cbd7
--- /dev/null
+++ b/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/ConsumeModel.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+package org.apache.rocketmq.jms;
+
+public enum ConsumeModel {
+    SYNC,
+    ASYNC
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq-externals/blob/725026db/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/DeliverMessageService.java
----------------------------------------------------------------------
diff --git 
a/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/DeliverMessageService.java 
b/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/DeliverMessageService.java
new file mode 100644
index 0000000..a534bd3
--- /dev/null
+++ 
b/rocketmq-jms/src/main/java/org/apache/rocketmq/jms/DeliverMessageService.java
@@ -0,0 +1,275 @@
+/*
+ * 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.
+ */
+
+package org.apache.rocketmq.jms;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.JMSRuntimeException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.rocketmq.client.ClientConfig;
+import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.ServiceThread;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.jms.exception.MessageExpiredException;
+import org.apache.rocketmq.jms.hook.ReceiveMessageHook;
+import org.apache.rocketmq.jms.msg.convert.RMQ2JMSMessageConvert;
+import org.apache.rocketmq.jms.support.JMSUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static java.lang.String.format;
+
+/**
+ * Service deliver messages synchronous or asynchronous.
+ */
+public class DeliverMessageService extends ServiceThread {
+
+    private static final Logger log = 
LoggerFactory.getLogger(DeliverMessageService.class);
+    private static final AtomicLong COUNTER = new AtomicLong(0L);
+    private static final int PULL_BATCH_SIZE = 100;
+
+    private RocketMQConsumer consumer;
+    private DefaultMQPullConsumer rocketMQPullConsumer;
+    private Destination destination;
+    private String consumerGroup;
+    private String topicName;
+    private ConsumeModel consumeModel = ConsumeModel.SYNC;
+
+    /** only support RMQ subExpression */
+    private String messageSelector;
+    private ReceiveMessageHook hook = new ReceiveMessageHook();
+
+    /**
+     * If durable is true, consume message from the offset consumed last time.
+     * Otherwise consume from the max offset
+     */
+    private boolean durable = false;
+    private boolean shared = false;
+
+    private BlockingQueue<MessageWrapper> msgQueue = new 
ArrayBlockingQueue(PULL_BATCH_SIZE);
+    private volatile boolean pause = true;
+    private final long index = COUNTER.incrementAndGet();
+
+    private Map<MessageQueue, Long> offsetMap = new HashMap();
+
+    public DeliverMessageService(RocketMQConsumer consumer, Destination 
destination, String consumerGroup,
+        String messageSelector, boolean durable, boolean shared) {
+        this.consumer = consumer;
+        this.destination = destination;
+        this.consumerGroup = consumerGroup;
+        this.messageSelector = messageSelector;
+        this.durable = durable;
+        this.shared = shared;
+
+        this.topicName = JMSUtils.getDestinationName(destination);
+
+        createAndStartRocketMQPullConsumer();
+
+        if (this.consumer.getSession().getConnection().isStarted()) {
+            this.recover();
+        }
+        else {
+            this.pause();
+        }
+    }
+
+    private void createAndStartRocketMQPullConsumer() {
+        final ClientConfig clientConfig = 
this.consumer.getSession().getConnection().getClientConfig();
+        this.rocketMQPullConsumer = new DefaultMQPullConsumer(consumerGroup);
+        
this.rocketMQPullConsumer.setNamesrvAddr(clientConfig.getNamesrvAddr());
+        
this.rocketMQPullConsumer.setInstanceName(clientConfig.getInstanceName());
+        this.rocketMQPullConsumer.setRegisterTopics(new 
HashSet(Arrays.asList(this.topicName)));
+
+        try {
+            this.rocketMQPullConsumer.start();
+        }
+        catch (MQClientException e) {
+            throw new JMSRuntimeException(format("Fail to start RocketMQ pull 
consumer, error msg:%s", ExceptionUtils.getStackTrace(e)));
+        }
+    }
+
+    @Override
+    public String getServiceName() {
+        return DeliverMessageService.class.getSimpleName() + "-" + this.index;
+    }
+
+    @Override
+    public void run() {
+        while (!isStopped()) {
+            if (pause) {
+                this.waitForRunning(1000);
+                continue;
+            }
+
+            try {
+                pullMessage();
+            }
+            catch (InterruptedException e) {
+                log.debug("Pulling messages service has been interrupted");
+            }
+            catch (Exception e) {
+                log.error("Error during pulling messages", e);
+            }
+        }
+    }
+
+    private void pullMessage() throws Exception {
+        Set<MessageQueue> mqs = getMessageQueues();
+
+        for (MessageQueue mq : mqs) {
+            Long offset = offsetMap.get(mq);
+            if (offset == null) {
+                offset = beginOffset(mq);
+            }
+            PullResult pullResult = 
this.rocketMQPullConsumer.pullBlockIfNotFound(mq, this.messageSelector, offset, 
PULL_BATCH_SIZE);
+
+            switch (pullResult.getPullStatus()) {
+                case FOUND:
+                    List<MessageExt> msgs = pullResult.getMsgFoundList();
+                    offsetMap.put(mq, pullResult.getMaxOffset());
+                    for (MessageExt msg : msgs) {
+                        handleMessage(msg, mq);
+                    }
+                    log.debug("Pull {} messages from 
topic:{},broker:{},queueId:{}", msgs.size(), mq.getTopic(), mq.getBrokerName(), 
mq.getQueueId());
+                    break;
+                case NO_NEW_MSG:
+                case NO_MATCHED_MSG:
+                    break;
+                case OFFSET_ILLEGAL:
+                    throw new JMSException("Error during pull 
message[reason:OFFSET_ILLEGAL]");
+            }
+        }
+    }
+
+    private Set<MessageQueue> getMessageQueues() throws MQClientException {
+        Set<MessageQueue> mqs = 
this.rocketMQPullConsumer.fetchSubscribeMessageQueues(this.topicName);
+        return mqs;
+    }
+
+    /**
+     * Refer to {@link #durable}.
+     *
+     * @param mq message queue
+     * @return offset
+     * @throws MQClientException
+     */
+    private Long beginOffset(MessageQueue mq) throws MQClientException {
+        return this.durable ? this.rocketMQPullConsumer.fetchConsumeOffset(mq, 
false) : this.rocketMQPullConsumer.maxOffset(mq);
+    }
+
+    /**
+     * If {@link #consumeModel} is {@link ConsumeModel#ASYNC}, messages pulled 
from broker
+     * are handled in {@link ConsumeMessageService} owned by its session.
+     *
+     * If {@link #consumeModel} is {@link ConsumeModel#SYNC}, messages pulled 
from broker are put
+     * into a memory blocking queue, waiting for the {@link 
MessageConsumer#receive()}
+     * using {@link BlockingQueue#poll()} to handle messages synchronous.
+     *
+     * @param msg to handle message
+     * @throws InterruptedException
+     * @throws JMSException
+     */
+    private void handleMessage(MessageExt msg, MessageQueue mq) throws 
InterruptedException, JMSException {
+        Message jmsMessage = RMQ2JMSMessageConvert.convert(msg);
+
+        try {
+            hook.before(jmsMessage);
+        }
+        catch (MessageExpiredException e) {
+            log.debug(e.getMessage());
+        }
+
+        final MessageWrapper wrapper = new MessageWrapper(jmsMessage, 
this.consumer, mq, msg.getQueueOffset());
+
+        switch (this.consumeModel) {
+            case SYNC:
+                this.msgQueue.put(wrapper);
+                break;
+            case ASYNC:
+                
this.consumer.getSession().getConsumeMessageService().put(wrapper);
+                break;
+            default:
+                throw new JMSException(format("Unsupported consume model[%s]", 
this.consumeModel));
+        }
+    }
+
+    public void ack(MessageQueue mq, Long offset) throws JMSException {
+        try {
+            this.rocketMQPullConsumer.updateConsumeOffset(mq, offset);
+        }
+        catch (MQClientException e) {
+            throw new JMSException(format("Fail to ack 
offset[mq:%s,offset:%s]", mq, offset));
+        }
+    }
+
+    public MessageWrapper poll() throws JMSException {
+        try {
+            return this.msgQueue.take();
+        }
+        catch (InterruptedException e) {
+            throw new JMSException(e.getMessage());
+        }
+    }
+
+    public MessageWrapper poll(long timeout, TimeUnit timeUnit) throws 
JMSException {
+        try {
+            return this.msgQueue.poll(timeout, timeUnit);
+        }
+        catch (InterruptedException e) {
+            throw new JMSException(e.getMessage());
+        }
+    }
+
+    public void pause() {
+        this.pause = true;
+    }
+
+    public void recover() {
+        this.pause = false;
+    }
+
+    public void close() {
+
+        this.stop();
+
+        this.rocketMQPullConsumer.shutdown();
+
+        this.shutdown(true);
+
+        log.debug("Success to close message delivery service:{}", 
getServiceName());
+    }
+
+    public void setConsumeModel(ConsumeModel consumeModel) {
+        this.consumeModel = consumeModel;
+    }
+}

Reply via email to