You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2018/12/14 08:24:06 UTC

[GitHub] vongosling closed pull request #2: Support configuration property with relaxed names

vongosling closed pull request #2: Support configuration property with relaxed names
URL: https://github.com/apache/rocketmq-spring/pull/2
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/README.md b/README.md
index 89ac93e..fc4689e 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ We are always very happy to have contributions, whether for trivial cleanups or
 
 Please see the complete sample [rocketmq-spring-boot-samples](rocketmq-spring-boot-samples)
 
-Note: Current RELEASE.VERSION=2.0.0
+Note: Current RELEASE.VERSION=2.0.1-SNAPSHOT (public review phase)
 
 ```xml
 <!--add dependency in pom.xml-->
@@ -54,7 +54,7 @@ Note: Current RELEASE.VERSION=2.0.0
 
 ```properties
 ## application.properties
-spring.rocketmq.nameServer=127.0.0.1:9876
+spring.rocketmq.name-server=127.0.0.1:9876
 spring.rocketmq.producer.group=my-group
 ```
 
@@ -93,12 +93,12 @@ public class ProducerApplication implements CommandLineRunner{
 > More relevant configurations for producing:
 >
 > ```properties
-> spring.rocketmq.producer.retryTimesWhenSendAsyncFailed=0
-> spring.rocketmq.producer.sendMessageTimeout=300000
-> spring.rocketmq.producer.compressMessageBodyOverHowmuch=4096
-> spring.rocketmq.producer.maxMessageSize=4194304
-> spring.rocketmq.producer.retryAnotherBrokerWhenNotStoreOk=false
-> spring.rocketmq.producer.retryTimesWhenSendFailed=2
+> spring.rocketmq.producer.retry-times-when-send-async-failed=0
+> spring.rocketmq.producer.send-message-timeout=300000
+> spring.rocketmq.producer.compress-message-body-threshold=4096
+> spring.rocketmq.producer.max-message-size=4194304
+> spring.rocketmq.producer.retry-another-broker-when-not-store-ok=false
+> spring.rocketmq.producer.retry-times-when-send-failed=2
 > ```
 
 
@@ -147,7 +147,7 @@ public class ProducerApplication implements CommandLineRunner{
 
 ```properties
 ## application.properties
-spring.rocketmq.nameServer=127.0.0.1:9876
+spring.rocketmq.name-server=127.0.0.1:9876
 ```
 
 > Note:
diff --git a/README_zh_CN.md b/README_zh_CN.md
index 168230d..8b4d136 100644
--- a/README_zh_CN.md
+++ b/README_zh_CN.md
@@ -30,7 +30,7 @@
 
 下面列出来了一些关键点,完整的示例请参考: [rocketmq-spring-boot-samples](rocketmq-spring-boot-samples)
 
-注意:当前的RELEASE.VERSION=2.0.0
+注意:当前的RELEASE.VERSION=2.0.1-SNAPSHOT 目前在公开review阶段。
 
 ```xml
 <!--在pom.xml中添加依赖-->
@@ -45,7 +45,7 @@
 
 ```properties
 ## application.properties
-spring.rocketmq.nameServer=127.0.0.1:9876
+spring.rocketmq.name-server=127.0.0.1:9876
 spring.rocketmq.producer.group=my-group
 ```
 
@@ -125,12 +125,12 @@ public class ProducerApplication implements CommandLineRunner{
 > 更多发送相关配置
 >
 > ```properties
-> spring.rocketmq.producer.retryTimesWhenSendAsyncFailed=0
-> spring.rocketmq.producer.sendMessageTimeout=300000
-> spring.rocketmq.producer.compressMessageBodyOverHowmuch=4096
-> spring.rocketmq.producer.maxMessageSize=4194304
-> spring.rocketmq.producer.retryAnotherBrokerWhenNotStoreOk=false
-> spring.rocketmq.producer.retryTimesWhenSendFailed=2
+> spring.rocketmq.producer.retry-times-when-send-async-failed=0
+> spring.rocketmq.producer.send-message-timeout=300000
+> spring.rocketmq.producer.compress-message-body-threshold=4096
+> spring.rocketmq.producer.max-message-size=4194304
+> spring.rocketmq.producer.retry-another-broker-when-not-store-ok=false
+> spring.rocketmq.producer.retry-times-when-send-failed=2
 > ```
 
 
@@ -138,7 +138,7 @@ public class ProducerApplication implements CommandLineRunner{
 
 ```properties
 ## application.properties
-spring.rocketmq.nameServer=127.0.0.1:9876
+spring.rocketmq.name-server=127.0.0.1:9876
 ```
 
 > 注意:
diff --git a/pom.xml b/pom.xml
index 7ca40cc..ba39a3e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
 
     <groupId>org.apache.rocketmq</groupId>
     <artifactId>rocketmq-spring-boot-build</artifactId>
-    <version>2.0.0</version>
+    <version>2.0.1-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <name>RocketMQ Spring Boot Build</name>
diff --git a/rocketmq-spring-boot-parent/pom.xml b/rocketmq-spring-boot-parent/pom.xml
index 005c2cb..b337386 100644
--- a/rocketmq-spring-boot-parent/pom.xml
+++ b/rocketmq-spring-boot-parent/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.rocketmq</groupId>
         <artifactId>rocketmq-spring-boot-build</artifactId>
-        <version>2.0.0</version>
+        <version>2.0.1-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
@@ -39,7 +39,7 @@
         <spring.boot.version>2.0.5.RELEASE</spring.boot.version>
         <spring.version>5.1.0.RELEASE</spring.version>
 
-        <rocketmq.spring.boot.version>2.0.0</rocketmq.spring.boot.version>
+        <rocketmq.spring.boot.version>${project.version}</rocketmq.spring.boot.version>
 
         <rocketmq-version>4.3.2</rocketmq-version>
         <slf4j.version>1.6.1</slf4j.version>
diff --git a/rocketmq-spring-boot-samples/pom.xml b/rocketmq-spring-boot-samples/pom.xml
index 7b5eaa5..c4568fd 100644
--- a/rocketmq-spring-boot-samples/pom.xml
+++ b/rocketmq-spring-boot-samples/pom.xml
@@ -36,7 +36,7 @@
     </modules>
 
     <properties>
-        <rocketmq-spring-boot-starter-version>2.0.0</rocketmq-spring-boot-starter-version>
+        <rocketmq-spring-boot-starter-version>2.0.1-SNAPSHOT</rocketmq-spring-boot-starter-version>
     </properties>
 
     <dependencies>
diff --git a/rocketmq-spring-boot-samples/rocketmq-produce-demo/src/main/resources/application.properties b/rocketmq-spring-boot-samples/rocketmq-produce-demo/src/main/resources/application.properties
index 2187442..f14b1ba 100644
--- a/rocketmq-spring-boot-samples/rocketmq-produce-demo/src/main/resources/application.properties
+++ b/rocketmq-spring-boot-samples/rocketmq-produce-demo/src/main/resources/application.properties
@@ -1,4 +1,4 @@
-spring.rocketmq.nameServer=localhost:9876
+spring.rocketmq.name-server=localhost:9876
 spring.rocketmq.producer.group=my-group1
 spring.rocketmq.topic=string-topic
 spring.rocketmq.orderTopic=order-paid-topic
diff --git a/rocketmq-spring-boot-starter/pom.xml b/rocketmq-spring-boot-starter/pom.xml
index cd88b71..763fce6 100644
--- a/rocketmq-spring-boot-starter/pom.xml
+++ b/rocketmq-spring-boot-starter/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.rocketmq</groupId>
         <artifactId>rocketmq-spring-boot-parent</artifactId>
-        <version>2.0.0</version>
+        <version>2.0.1-SNAPSHOT</version>
         <relativePath>../rocketmq-spring-boot-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/rocketmq-spring-boot/pom.xml b/rocketmq-spring-boot/pom.xml
index 94e528c..3cf574d 100644
--- a/rocketmq-spring-boot/pom.xml
+++ b/rocketmq-spring-boot/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.rocketmq</groupId>
         <artifactId>rocketmq-spring-boot-parent</artifactId>
-        <version>2.0.0</version>
+        <version>2.0.1-SNAPSHOT</version>
         <relativePath>../rocketmq-spring-boot-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQAutoConfiguration.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQAutoConfiguration.java
index 5eb97a5..b65dee1 100644
--- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQAutoConfiguration.java
+++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQAutoConfiguration.java
@@ -58,7 +58,7 @@ public DefaultMQProducer defaultMQProducer(RocketMQProperties rocketMQProperties
         producer.setRetryTimesWhenSendFailed(producerConfig.getRetryTimesWhenSendFailed());
         producer.setRetryTimesWhenSendAsyncFailed(producerConfig.getRetryTimesWhenSendAsyncFailed());
         producer.setMaxMessageSize(producerConfig.getMaxMessageSize());
-        producer.setCompressMsgBodyOverHowmuch(producerConfig.getCompressMessageBodyOverHowmuch());
+        producer.setCompressMsgBodyOverHowmuch(producerConfig.getCompressMessageBodyThreshold());
         producer.setRetryAnotherBrokerWhenNotStoreOK(producerConfig.isRetryAnotherBrokerWhenNotStoreOk());
 
         return producer;
@@ -91,7 +91,8 @@ public TransactionHandlerRegistry transactionHandlerRegistry(RocketMQTemplate te
     @Bean(name = RocketMQConfigUtils.ROCKETMQ_TRANSACTION_ANNOTATION_PROCESSOR_BEAN_NAME)
     @ConditionalOnBean(TransactionHandlerRegistry.class)
     @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
-    public static RocketMQTransactionAnnotationProcessor transactionAnnotationProcessor(TransactionHandlerRegistry transactionHandlerRegistry) {
+    public static RocketMQTransactionAnnotationProcessor transactionAnnotationProcessor(
+        TransactionHandlerRegistry transactionHandlerRegistry) {
         return new RocketMQTransactionAnnotationProcessor(transactionHandlerRegistry);
     }
 
diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQProperties.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQProperties.java
index 8590e05..07e9e06 100644
--- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQProperties.java
+++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/RocketMQProperties.java
@@ -61,7 +61,7 @@ public void setProducer(RocketMQProperties.Producer producer) {
         /**
          * Compress message body threshold, namely, message body larger than 4k will be compressed on default.
          */
-        private int compressMessageBodyOverHowmuch = 1024 * 4;
+        private int compressMessageBodyThreshold = 1024 * 4;
 
         /**
          * Maximum number of retry to perform internally before claiming sending failure in synchronous mode.
@@ -101,12 +101,12 @@ public void setSendMessageTimeout(int sendMessageTimeout) {
             this.sendMessageTimeout = sendMessageTimeout;
         }
 
-        public int getCompressMessageBodyOverHowmuch() {
-            return compressMessageBodyOverHowmuch;
+        public int getCompressMessageBodyThreshold() {
+            return compressMessageBodyThreshold;
         }
 
-        public void setCompressMessageBodyOverHowmuch(int compressMessageBodyOverHowmuch) {
-            this.compressMessageBodyOverHowmuch = compressMessageBodyOverHowmuch;
+        public void setCompressMessageBodyThreshold(int compressMessageBodyThreshold) {
+            this.compressMessageBodyThreshold = compressMessageBodyThreshold;
         }
 
         public int getRetryTimesWhenSendFailed() {
diff --git a/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/config/RocketMQAutoConfigurationTest.java b/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/config/RocketMQAutoConfigurationTest.java
index fd4056f..c0fa370 100644
--- a/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/config/RocketMQAutoConfigurationTest.java
+++ b/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/config/RocketMQAutoConfigurationTest.java
@@ -48,8 +48,8 @@ public void testDefaultMQProducerNotCreatedByDefault() {
 
 
     @Test
-    public void testDefaultMQProducer() {
-        runner.withPropertyValues("spring.rocketmq.name-server=127.0.0.1:9876",
+    public void testDefaultMQProducerWithRelaxPropertyName() {
+        runner.withPropertyValues("spring.rocketmq.nameServer=127.0.0.1:9876",
                 "spring.rocketmq.producer.group=spring_rocketmq").
                 run((context) -> {
                     assertThat(context).hasSingleBean(DefaultMQProducer.class);
@@ -58,6 +58,16 @@ public void testDefaultMQProducer() {
 
     }
 
+    @Test
+    public void testDefaultMQProducer() {
+        runner.withPropertyValues("spring.rocketmq.name-server=127.0.0.1:9876",
+            "spring.rocketmq.producer.group=spring_rocketmq").
+            run((context) -> {
+                assertThat(context).hasSingleBean(DefaultMQProducer.class);
+            });
+
+    }
+
     @Test
     public void testRocketMQListenerContainer() {
         runner.withPropertyValues("spring.rocketmq.name-server=127.0.0.1:9876").


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services