Jelajahi Sumber

feat: 发布1.3.0

Uncarbon 4 tahun lalu
induk
melakukan
3c27af29f0
79 mengubah file dengan 3359 tambahan dan 88 penghapusan
  1. 1 1
      helio-core/pom.xml
  2. 4 2
      helio-core/src/main/java/cc/uncarbon/framework/core/config/HelioPropertiesAutoConfiguration.java
  3. 23 0
      helio-core/src/main/java/cc/uncarbon/framework/core/constant/HelioConstant.java
  4. 1 1
      helio-core/src/main/java/cc/uncarbon/framework/core/context/TenantContext.java
  5. 9 4
      helio-core/src/main/java/cc/uncarbon/framework/core/context/UserContext.java
  6. 38 10
      helio-core/src/main/java/cc/uncarbon/framework/core/context/UserContextHolder.java
  7. 7 22
      helio-core/src/main/java/cc/uncarbon/framework/core/props/HelioProperties.java
  8. 1 1
      helio-core/src/main/resources/META-INF/spring.factories
  9. 1 1
      helio-starter-aop/pom.xml
  10. 1 1
      helio-starter-cloud/pom.xml
  11. 1 1
      helio-starter-crud/pom.xml
  12. 1 1
      helio-starter-dubbo/pom.xml
  13. 1 1
      helio-starter-knife4j/pom.xml
  14. 1 1
      helio-starter-redis/pom.xml
  15. 41 0
      helio-starter-rocketmq-aliyun/pom.xml
  16. 67 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/CommonMessage.java
  17. 77 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/MessageListener.java
  18. 50 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/OrderMessage.java
  19. 53 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/RocketListener.java
  20. 44 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/RocketMessage.java
  21. 33 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/ShardingKey.java
  22. 34 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/StartDeliverTime.java
  23. 79 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/TransactionMessage.java
  24. 123 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/aspect/RocketAspect.java
  25. 84 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/config/AliyunRocketAutoConfiguration.java
  26. 78 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/container/RocketConsumerContainer.java
  27. 64 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/container/RocketProducerContainer.java
  28. 47 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/consumer/AbstractRocketListener.java
  29. 64 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/consumer/DefaultBatchMessageListener.java
  30. 62 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/consumer/DefaultMessageListener.java
  31. 64 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/consumer/DefaultMessageOrderListener.java
  32. 51 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ConsumerFactory.java
  33. 52 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ConsumerPropertiesFactory.java
  34. 53 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/MessageFactory.java
  35. 37 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/MethodFactory.java
  36. 73 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ProducerConsumerFactory.java
  37. 57 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ProducerFactory.java
  38. 44 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ProducerPropertiesFactory.java
  39. 45 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/PropertiesFactory.java
  40. 60 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/SendMessageFactory.java
  41. 44 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ShardingKeyFactory.java
  42. 46 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/StartDeliverTimeFactory.java
  43. 104 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ThreadPoolFactory.java
  44. 77 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/ConsumerFactoryExecution.java
  45. 53 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/MethodFactoryExecution.java
  46. 54 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/ProducerFactoryExecution.java
  47. 66 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/SendMessageFactoryExecution.java
  48. 37 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/ThreadPoolExecutorExecution.java
  49. 51 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/producer/DefaultLocalTransactionChecker.java
  50. 46 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/producer/DefaultLocalTransactionExecutor.java
  51. 53 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/producer/DefaultSendCallback.java
  52. 41 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/producer/MessageSendType.java
  53. 32 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/serializer/Base64Serializer.java
  54. 32 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/serializer/HutoolJsonSerializer.java
  55. 44 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/serializer/JacksonJsonSerializer.java
  56. 45 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/serializer/RocketSerializer.java
  57. 64 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/strategy/ProducerStrategy.java
  58. 77 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/strategy/PutProducerStrategy.java
  59. 63 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/strategy/RocketConsumerStrategy.java
  60. 52 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/strategy/SendMessageStrategy.java
  61. 43 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/utils/AnnotatedMethodsUtils.java
  62. 69 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/utils/ApplicationContextUtils.java
  63. 55 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/utils/AspectUtils.java
  64. 48 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/utils/InterceptRocket.java
  65. 40 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/exception/RocketException.java
  66. 104 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/props/AliyunRocketProperties.java
  67. 67 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/thread/AbstractConsumerThread.java
  68. 65 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/thread/AbstractProducerThread.java
  69. 74 0
      helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/thread/AbstractSendMessageThread.java
  70. 2 0
      helio-starter-rocketmq-aliyun/src/main/resources/META-INF/spring.factories
  71. 1 1
      helio-starter-satoken/pom.xml
  72. 3 2
      helio-starter-satoken/src/main/java/cc/uncarbon/framework/satoken/interceptor/DefaultSaTokenParseInterceptor.java
  73. 1 1
      helio-starter-seata/pom.xml
  74. 1 1
      helio-starter-test/pom.xml
  75. 1 1
      helio-starter-web/pom.xml
  76. 0 26
      helio-starter-web/src/main/java/cc/uncarbon/framework/web/config/CorsAutoConfiguration.java
  77. 55 0
      helio-starter-web/src/main/java/cc/uncarbon/framework/web/interceptor/DefaultTenantParseInterceptor.java
  78. 1 2
      helio-starter-web/src/main/resources/META-INF/spring.factories
  79. 22 7
      pom.xml

+ 1 - 1
helio-core/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 4 - 2
helio-core/src/main/java/cc/uncarbon/framework/core/config/EnableConfigurationPropertiesAutoConfiguration.java → helio-core/src/main/java/cc/uncarbon/framework/core/config/HelioPropertiesAutoConfiguration.java

@@ -5,9 +5,11 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
 import org.springframework.context.annotation.Configuration;
 
 /**
+ * 自动配置文件读取
+ *
  * @author Uncarbon
  */
-@EnableConfigurationProperties(HelioProperties.class)
+@EnableConfigurationProperties(value = {HelioProperties.class})
 @Configuration
-public class EnableConfigurationPropertiesAutoConfiguration {
+public class HelioPropertiesAutoConfiguration {
 }

+ 23 - 0
helio-core/src/main/java/cc/uncarbon/framework/core/constant/HelioConstant.java

@@ -17,8 +17,26 @@ public interface HelioConstant {
     }
 
     interface Version {
+        /**
+         * replaced with HTTP_API_VERSION_V1
+         */
+        @Deprecated
         String APP_API_VERSION_V1 = "/api/v1";
+
+        /**
+         * replaced with HTTP_API_VERSION_V1
+         */
+        @Deprecated
         String SAAS_API_VERSION_V1 = "/api/v1";
+
+        /**
+         * HTTP API 版本 v1
+         */
+        String HTTP_API_VERSION_V1 = "/api/v1";
+
+        /**
+         * DUBBO API 版本 v1
+         */
         String DUBBO_VERSION_V1 = "1.0.0";
     }
 
@@ -74,6 +92,11 @@ public interface HelioConstant {
          */
         String SQL_LIMIT_1 = " LIMIT 1";
 
+        /**
+         * SQL 列名 id
+         */
+        String SQL_COLUMN_ID = " id ";
+
     }
 
     interface Regex {

+ 1 - 1
helio-core/src/main/java/cc/uncarbon/framework/core/context/TenantContext.java

@@ -14,7 +14,7 @@ import java.io.Serializable;
  * @author Uncarbon
  */
 @Accessors(chain = true)
-@SuperBuilder(toBuilder = true)
+@SuperBuilder
 @AllArgsConstructor
 @NoArgsConstructor
 @Data

+ 9 - 4
helio-core/src/main/java/cc/uncarbon/framework/core/context/UserContext.java

@@ -18,12 +18,14 @@ import java.util.Map;
  * @author Uncarbon
  */
 @Accessors(chain = true)
-@SuperBuilder(toBuilder = true)
+@SuperBuilder
 @AllArgsConstructor
 @NoArgsConstructor
 @Data
 public class UserContext implements Serializable {
 
+    private static final long SerialVersionUID = 1L;
+
     @ApiModelProperty(value = "用户ID")
     private Long userId;
 
@@ -36,14 +38,17 @@ public class UserContext implements Serializable {
     @ApiModelProperty(value = "用户类型")
     private HelioBaseEnum<?> userType;
 
-    @ApiModelProperty(value = "用户拥有角色(后台管理使用)")
+    @ApiModelProperty(value = "用户对应角色ID数组(后台管理使用, 建议从小到大排序)")
+    private List<Long> rolesIds;
+
+    @ApiModelProperty(value = "用户对应角色串(后台管理使用)")
     private List<String> roles;
 
-    @ApiModelProperty(value = "用户拥有权限(后台管理使用, 决定可见菜单及按钮)")
+    @ApiModelProperty(value = "用户拥有权限(后台管理使用, 决定可见菜单及按钮)")
     private List<String> permissions;
 
     @ApiModelProperty(value = "附加数据")
-    private Map<String, String> extraData;
+    private Map<String, Object> extraData;
 
     @ApiModelProperty(value = "所属租户")
     private TenantContext relationalTenant = TenantContext.builder()

+ 38 - 10
helio-core/src/main/java/cc/uncarbon/framework/core/context/UserContextHolder.java

@@ -1,11 +1,13 @@
 package cc.uncarbon.framework.core.context;
 
-import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.ttl.TransmittableThreadLocal;
 import lombok.experimental.UtilityClass;
 
+import java.util.Optional;
+
 /**
  * 存储当前用户上下文
+ *
  * @author Uncarbon
  */
 @UtilityClass
@@ -14,8 +16,42 @@ public class UserContextHolder {
     private final TransmittableThreadLocal<UserContext> THREAD_LOCAL_USER = new TransmittableThreadLocal<>();
 
 
+    /**
+     * 是否真正存有当前用户上下文,即是否实际登录
+     *
+     * @return true or false
+     */
+    public boolean isActuallyHold() {
+        return THREAD_LOCAL_USER.get() != null;
+    }
+
+    /**
+     * 获取当前用户上下文
+     * 注意:即使未登录情况下,该方法也不会返回 null ,而是返回一个空对象
+     *
+     * @return 当前用户上下文
+     */
+    public UserContext getUserContext() {
+        /*
+        必须新创建,否则可能出现租户ID无法切换的BUG
+        不能用 .orElse ,即使条件不满足也会new
+         */
+        return Optional.ofNullable(THREAD_LOCAL_USER.get()).orElseGet(UserContext::new);
+    }
+
+    /**
+     * 获取 Optional 化的当前用户上下文
+     * 用于函数式编码
+     *
+     * @return 当前用户上下文 Optional
+     */
+    public Optional<UserContext> getUserContextOptional() {
+        return Optional.ofNullable(THREAD_LOCAL_USER.get());
+    }
+
     /**
      * 设置当前用户上下文
+     *
      * @param userContext 当前用户上下文
      */
     public void setUserContext(UserContext userContext) {
@@ -23,16 +59,8 @@ public class UserContextHolder {
             THREAD_LOCAL_USER.remove();
             return;
         }
-        THREAD_LOCAL_USER.set(userContext);
-    }
 
-    /**
-     * 获取当前用户上下文, 确保不返回空
-     * @return 当前用户上下文
-     */
-    public UserContext getUserContext() {
-        // 必须新创建,否则可能出现租户ID无法切换的BUG
-        return ObjectUtil.defaultIfNull(THREAD_LOCAL_USER.get(), new UserContext());
+        THREAD_LOCAL_USER.set(userContext);
     }
 
     /**

+ 7 - 22
helio-core/src/main/java/cc/uncarbon/framework/core/props/HelioProperties.java

@@ -2,7 +2,6 @@ package cc.uncarbon.framework.core.props;
 
 import cc.uncarbon.framework.core.enums.IdGeneratorStrategyEnum;
 import cc.uncarbon.framework.core.enums.TenantIsolateLevelEnum;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -10,10 +9,10 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
+ * 配置文件读取类
+ *
  * @author Uncarbon
- * 读取配置文件里的值
  */
-
 @ConfigurationProperties(prefix = "helio", ignoreInvalidFields = true)
 @Data
 public class HelioProperties {
@@ -29,7 +28,6 @@ public class HelioProperties {
         /**
          * 放行路由地址(不进行登录校验)
          */
-        @ApiModelProperty(value = "放行路由地址(不进行登录校验)")
         private final List<String> excludeRoutes = new ArrayList<>(64);
 
     }
@@ -57,7 +55,6 @@ public class HelioProperties {
          * 参考com.baomidou.mybatisplus.annotation.DbType
          * 默认为mysql
          */
-        @ApiModelProperty(value = "用的哪种数据库", notes = "如: mysql postgresql(参考com.baomidou.mybatisplus.annotation.DbType)(默认为mysql)")
         private String dbType = "mysql";
 
 
@@ -68,20 +65,17 @@ public class HelioProperties {
              * 是否启用多租户
              * 默认为false
              */
-            @ApiModelProperty(value = "是否启用多租户", notes = "默认为false")
             private Boolean enabled = false;
 
             /**
              * 多租户隔离级别
              * 默认为行级
              */
-            @ApiModelProperty(value = "多租户隔离级别", notes = "默认为行级")
             private TenantIsolateLevelEnum isolateLevel = TenantIsolateLevelEnum.LINE;
 
             /**
              * 哪些表不启用租户隔离
              */
-            @ApiModelProperty(value = "哪些表不启用租户隔离")
             private List<String> ignoredTables = new ArrayList<>(64);
 
         }
@@ -93,7 +87,6 @@ public class HelioProperties {
              * 是否启用乐观锁
              * 默认为false
              */
-            @ApiModelProperty(value = "是否启用乐观锁", notes = "默认为false")
             private Boolean enabled = false;
 
         }
@@ -101,27 +94,22 @@ public class HelioProperties {
         @Data
         public static class IdGenerator {
 
+            /**
+             * 雪花ID-起始时刻
+             * 默认为2021-01-01
+             */
+            String epochDate = "2021-01-01";
             /**
              * ID生成器策略
              * 默认为SNOWFLAKE
              */
-            @ApiModelProperty(value = "ID生成器策略", notes = "默认为SNOWFLAKE")
             private IdGeneratorStrategyEnum strategy = IdGeneratorStrategyEnum.SNOWFLAKE;
-
             /**
              * 雪花ID-数据中心ID
              * 默认为0
              */
-            @ApiModelProperty(value = "雪花ID-数据中心ID", notes = "默认为0")
             private Long datacenterId = 0L;
 
-            /**
-             * 雪花ID-起始时刻
-             * 默认为2021-01-01
-             */
-            @ApiModelProperty(value = "雪花ID-起始时刻", notes = "默认为2021-01-01")
-            String epochDate = "2021-01-01";
-
         }
     }
 
@@ -131,19 +119,16 @@ public class HelioProperties {
         /**
          * 标题
          */
-        @ApiModelProperty(value = "标题")
         private String title = "";
 
         /**
          * 简介
          */
-        @ApiModelProperty(value = "简介")
         private String description = "";
 
         /**
          * 版本号
          */
-        @ApiModelProperty(value = "版本号")
         private String version = "";
 
     }

+ 1 - 1
helio-core/src/main/resources/META-INF/spring.factories

@@ -1,2 +1,2 @@
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-  cc.uncarbon.framework.core.config.EnableConfigurationPropertiesAutoConfiguration
+  cc.uncarbon.framework.core.config.HelioPropertiesAutoConfiguration

+ 1 - 1
helio-starter-aop/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
helio-starter-cloud/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
helio-starter-crud/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
helio-starter-dubbo/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
helio-starter-knife4j/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
helio-starter-redis/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 41 - 0
helio-starter-rocketmq-aliyun/pom.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>helio-starters</artifactId>
+        <groupId>cc.uncarbon.framework</groupId>
+        <version>1.3.0</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>helio-starter-rocketmq-aliyun</artifactId>
+
+    <properties>
+
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>cc.uncarbon.framework</groupId>
+            <artifactId>helio-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>cc.uncarbon.framework</groupId>
+            <artifactId>helio-starter-aop</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun.openservices</groupId>
+            <artifactId>ons-client</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

+ 67 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/CommonMessage.java

@@ -0,0 +1,67 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.annotation;
+
+import cc.uncarbon.framework.rocketmq.core.producer.DefaultSendCallback;
+import cc.uncarbon.framework.rocketmq.core.producer.MessageSendType;
+import com.aliyun.openservices.ons.api.SendCallback;
+
+import java.lang.annotation.*;
+
+/**
+ * ClassName: CommonMessage
+ * Description:
+ * date: 2019/5/3 11:16
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface CommonMessage {
+	/**
+	 * Message 所属的 Topic
+	 *
+	 * @return String
+	 */
+	String topic() default "";
+
+	/**
+	 * 订阅指定 Topic 下的 Tags:
+	 * 1. * 表示订阅所有消息
+	 * 2. TagA || TagB || TagC 表示订阅 TagA 或 TagB 或 TagC 的消息
+	 *
+	 * @return String
+	 */
+	String tag() default "*";
+
+	/**
+	 * 消息发送类型 默认异步
+	 *
+	 * @return MessageSendType
+	 */
+	MessageSendType messageSendType() default MessageSendType.SEND_ASYNC;
+
+	/**
+	 * 自定义SendCallback类
+	 *
+	 * @return callback
+	 */
+	Class<? extends SendCallback> callback() default DefaultSendCallback.class;
+}

+ 77 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/MessageListener.java

@@ -0,0 +1,77 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.annotation;
+
+import org.springframework.stereotype.Component;
+
+import java.lang.annotation.*;
+
+/**
+ * ClassName: MessageListener
+ * Description:
+ * date: 2019/4/26 22:37
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+@Component
+public @interface MessageListener {
+	/**
+	 * Message 所属的 Topic
+	 *
+	 * @return String
+	 */
+	String topic() default "";
+
+	/**
+	 * 订阅指定 Topic 下的 Tags:
+	 * 1. * 表示订阅所有消息
+	 * 2. TagA || TagB || TagC 表示订阅 TagA 或 TagB 或 TagC 的消息
+	 *
+	 * @return String
+	 */
+	String tag() default "*";
+
+	/**
+	 * 是否为顺序消息
+	 *
+	 * @return Boolean
+	 */
+
+	boolean orderConsumer() default false;
+
+	/**
+	 * 是否为批量消息
+	 *
+	 * @return Boolean
+	 */
+	boolean batchConsumer() default false;
+
+	/**
+	 * 设置批量消费最大消息数量,当指定Topic的消息数量已经攒够128条,SDK立即执行回调进行消费.默认值:32,取值范围:1~1024.
+	 */
+	int consumeMessageBatchMaxSize() default 32;
+
+	/**
+	 * 设置批量消费最大等待时长,当等待时间达到10秒,SDK立即执行回调进行消费.默认值:0,取值范围:0~450,单位:秒.
+	 */
+	int batchConsumeMaxAwaitDurationInSeconds() default 0;
+}

+ 50 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/OrderMessage.java

@@ -0,0 +1,50 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.annotation;
+
+
+import java.lang.annotation.*;
+
+/**
+ * ClassName: OrderMessage
+ * Description:
+ * date: 2019/4/27 21:36
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OrderMessage {
+    /**
+     * Message 所属的 Topic
+     *
+     * @return String
+     */
+    String topic() default "";
+
+    /**
+     * 订阅指定 Topic 下的 Tags:
+     * 1. * 表示订阅所有消息
+     * 2. TagA || TagB || TagC 表示订阅 TagA 或 TagB 或 TagC 的消息
+     *
+     * @return String
+     */
+    String tag() default "*";
+}

+ 53 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/RocketListener.java

@@ -0,0 +1,53 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.annotation;
+
+import com.aliyun.openservices.ons.api.PropertyValueConst;
+import org.springframework.stereotype.Component;
+
+import java.lang.annotation.*;
+
+/**
+ * ClassName: RocketListener
+ * Description:
+ * date: 2019/4/26 21:35
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+@Component
+public @interface RocketListener {
+	/**
+	 * 您在控制台创建的 Group ID
+	 *
+	 * @return String
+	 */
+	String groupID() default "";
+
+	/**
+	 * 消费模式,默认集群消费
+	 *
+	 * @return String
+	 */
+	String messageModel() default PropertyValueConst.CLUSTERING;
+
+
+}

+ 44 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/RocketMessage.java

@@ -0,0 +1,44 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.annotation;
+
+import org.springframework.stereotype.Component;
+
+import java.lang.annotation.*;
+
+/**
+ * ClassName: RocketMessage
+ * Description:
+ * date: 2019/4/26 21:36
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Component
+@Documented
+public @interface RocketMessage {
+	/**
+	 * 您在控制台创建的 Group ID
+	 *
+	 * @return String
+	 */
+	String groupID() default "";
+
+}

+ 33 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/ShardingKey.java

@@ -0,0 +1,33 @@
+/**
+ * Copyright 2021 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * Classname: ShardingKey
+ * Description:
+ * Date: 2021/11/3 19:57
+ *
+ * @author ThierrySquirrel
+ * @since JDK 11
+ */
+@Target({ElementType.PARAMETER})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface ShardingKey {
+}

+ 34 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/StartDeliverTime.java

@@ -0,0 +1,34 @@
+/**
+ * Copyright 2020 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * ClassName: StartDeliverTime
+ * Description:
+ * date: 2020/1/29 19:05
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Target({ElementType.PARAMETER})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface StartDeliverTime {
+}

+ 79 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/annotation/TransactionMessage.java

@@ -0,0 +1,79 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.annotation;
+
+import cc.uncarbon.framework.rocketmq.core.producer.DefaultLocalTransactionChecker;
+import cc.uncarbon.framework.rocketmq.core.producer.DefaultLocalTransactionExecutor;
+import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker;
+import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
+import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
+
+import java.lang.annotation.*;
+
+/**
+ * ClassName: TransactionMessage
+ * Description:
+ * date: 2019/4/27 21:39
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface TransactionMessage {
+	/**
+	 * Message 所属的 Topic
+	 *
+	 * @return String
+	 */
+	String topic() default "";
+
+	/**
+	 * 订阅指定 Topic 下的 Tags:
+	 * 1. * 表示订阅所有消息
+	 * 2. TagA || TagB || TagC 表示订阅 TagA 或 TagB 或 TagC 的消息
+	 *
+	 * @return String
+	 */
+	String tag() default "*";
+
+	/**
+	 * 触发消息回查后的操作:默认提交(最终一致性)
+	 * 未收到消息确认时,会触发消息回查
+	 * 例如消费长时间未发送
+	 * 注意,正常情况下不会触发消息回查
+	 *
+	 * @return TransactionStatus
+	 */
+	TransactionStatus transactionStatus() default TransactionStatus.CommitTransaction;
+
+	/**
+	 * 自定义LocalTransactionChecker类
+	 *
+	 * @return checker类对象
+	 */
+	Class<? extends LocalTransactionChecker> checker() default DefaultLocalTransactionChecker.class;
+
+	/**
+	 * 自定义LocalTransactionExecutor类
+	 *
+	 * @return executor类对象
+	 */
+	Class<? extends LocalTransactionExecuter> executor() default DefaultLocalTransactionExecutor.class;
+}

+ 123 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/aspect/RocketAspect.java

@@ -0,0 +1,123 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.aspect;
+
+import cc.uncarbon.framework.rocketmq.annotation.CommonMessage;
+import cc.uncarbon.framework.rocketmq.annotation.OrderMessage;
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.annotation.TransactionMessage;
+import cc.uncarbon.framework.rocketmq.core.factory.ShardingKeyFactory;
+import cc.uncarbon.framework.rocketmq.core.factory.StartDeliverTimeFactory;
+import cc.uncarbon.framework.rocketmq.core.factory.ThreadPoolFactory;
+import cc.uncarbon.framework.rocketmq.core.utils.AspectUtils;
+import cc.uncarbon.framework.rocketmq.core.utils.InterceptRocket;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import lombok.Data;
+import lombok.NonNull;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import java.util.Map;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * ClassName: RocketAspect
+ * Description:
+ * date: 2019/4/28 21:07
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Aspect
+@Slf4j
+@Data
+public class RocketAspect implements ApplicationContextAware {
+    private Map<String, Object> consumerContainer;
+    private AliyunRocketProperties rocketProperties;
+    private ThreadPoolExecutor threadPoolExecutor;
+    private ApplicationContext applicationContext;
+
+    public RocketAspect(Map<String, Object> consumerContainer, AliyunRocketProperties rocketProperties) {
+        this.consumerContainer = consumerContainer;
+        this.rocketProperties = rocketProperties;
+        this.threadPoolExecutor = ThreadPoolFactory.createSendMessageThreadPoolExecutor(rocketProperties);
+    }
+
+    @Pointcut("@annotation(cc.uncarbon.framework.rocketmq.annotation.CommonMessage)")
+    public void commonMessagePointcut() {
+        log.debug("Start sending CommonMessage");
+    }
+
+    @Pointcut("@annotation(cc.uncarbon.framework.rocketmq.annotation.OrderMessage)")
+    public void orderMessagePointcut() {
+        log.debug("Start sending OrderMessage");
+    }
+
+    @Pointcut("@annotation(cc.uncarbon.framework.rocketmq.annotation.TransactionMessage)")
+    public void transactionMessagePointcut() {
+        log.debug("Start sending TransactionMessage");
+    }
+
+    @Around("commonMessagePointcut()")
+    public Object rockerMessageSend(ProceedingJoinPoint point) throws Throwable {
+        return InterceptRocket.intercept(
+                StartDeliverTimeFactory.getStartDeliverTime(point.getArgs(), AspectUtils.getParams(point)),
+                ShardingKeyFactory.getShardingKeyFactory(point.getArgs(), AspectUtils.getParams(point)),
+                AspectUtils.getDeclaringClassAnnotation(point, RocketMessage.class),
+                AspectUtils.getAnnotation(point, CommonMessage.class),
+                point.proceed(),
+                consumerContainer,
+                threadPoolExecutor,
+                applicationContext);
+    }
+
+    @Around("orderMessagePointcut()")
+    public Object orderMessageSend(ProceedingJoinPoint point) throws Throwable {
+        return InterceptRocket.intercept(
+                StartDeliverTimeFactory.getStartDeliverTime(point.getArgs(), AspectUtils.getParams(point)),
+                ShardingKeyFactory.getShardingKeyFactory(point.getArgs(), AspectUtils.getParams(point)),
+                AspectUtils.getDeclaringClassAnnotation(point, RocketMessage.class),
+                AspectUtils.getAnnotation(point, OrderMessage.class),
+                point.proceed(),
+                consumerContainer,
+                threadPoolExecutor,
+                applicationContext);
+    }
+
+    @Around("transactionMessagePointcut()")
+    public Object transactionMessageSend(ProceedingJoinPoint point) throws Throwable {
+        return InterceptRocket.intercept(
+                StartDeliverTimeFactory.getStartDeliverTime(point.getArgs(), AspectUtils.getParams(point)),
+                ShardingKeyFactory.getShardingKeyFactory(point.getArgs(), AspectUtils.getParams(point)),
+                AspectUtils.getDeclaringClassAnnotation(point, RocketMessage.class),
+                AspectUtils.getAnnotation(point, TransactionMessage.class),
+                point.proceed(),
+                consumerContainer,
+                threadPoolExecutor,
+                applicationContext);
+    }
+
+    @Override
+    public void setApplicationContext(@NonNull ApplicationContext applicationContext) {
+        this.applicationContext = applicationContext;
+    }
+}

+ 84 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/config/AliyunRocketAutoConfiguration.java

@@ -0,0 +1,84 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.config;
+
+import cc.uncarbon.framework.rocketmq.aspect.RocketAspect;
+import cc.uncarbon.framework.rocketmq.container.RocketConsumerContainer;
+import cc.uncarbon.framework.rocketmq.container.RocketProducerContainer;
+import cc.uncarbon.framework.rocketmq.core.serializer.JacksonJsonSerializer;
+import cc.uncarbon.framework.rocketmq.core.serializer.RocketSerializer;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.Resource;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * 阿里云 Rocket MQ 配置类
+ *
+ * @author ThierrySquirrel
+ * @author Uncarbon
+ */
+@EnableConfigurationProperties(value = {AliyunRocketProperties.class})
+@Configuration
+public class AliyunRocketAutoConfiguration {
+
+    @Resource
+    private AliyunRocketProperties rocketProperties;
+
+    @Resource
+    private Map<String, Object> consumerContainer;
+
+    @Resource
+    private RocketSerializer rocketSerializer;
+
+
+    @Bean
+    @ConditionalOnMissingBean(RocketConsumerContainer.class)
+    public RocketConsumerContainer rocketConsumerContainer() {
+        return new RocketConsumerContainer(rocketProperties, rocketSerializer);
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(RocketSerializer.class)
+    public RocketSerializer rocketSerializer() {
+        return new JacksonJsonSerializer();
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(Map.class)
+    public Map<String, Object> consumerContainer() {
+        return new ConcurrentHashMap<>(32);
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(RocketProducerContainer.class)
+    public RocketProducerContainer rocketProducerContainer() {
+        return new RocketProducerContainer(consumerContainer, rocketProperties);
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(RocketAspect.class)
+    public RocketAspect rockerAspect() {
+        return new RocketAspect(consumerContainer, rocketProperties);
+    }
+}

+ 78 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/container/RocketConsumerContainer.java

@@ -0,0 +1,78 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.container;
+
+import cc.uncarbon.framework.rocketmq.annotation.MessageListener;
+import cc.uncarbon.framework.rocketmq.annotation.RocketListener;
+import cc.uncarbon.framework.rocketmq.core.factory.ThreadPoolFactory;
+import cc.uncarbon.framework.rocketmq.core.factory.execution.ConsumerFactoryExecution;
+import cc.uncarbon.framework.rocketmq.core.factory.execution.MethodFactoryExecution;
+import cc.uncarbon.framework.rocketmq.core.factory.execution.ThreadPoolExecutorExecution;
+import cc.uncarbon.framework.rocketmq.core.serializer.RocketSerializer;
+import cc.uncarbon.framework.rocketmq.core.utils.AnnotatedMethodsUtils;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import lombok.NonNull;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import javax.annotation.PostConstruct;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * ClassName: RocketConsumerContainer
+ * Description:
+ * date: 2019/4/26 21:40
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class RocketConsumerContainer implements ApplicationContextAware {
+
+    private ApplicationContext applicationContext;
+
+    private final AliyunRocketProperties rocketProperties;
+
+    private final RocketSerializer mqSerializer;
+
+
+    public RocketConsumerContainer(AliyunRocketProperties rocketProperties, RocketSerializer rocketSerializer) {
+        this.rocketProperties = rocketProperties;
+        this.mqSerializer = rocketSerializer;
+    }
+
+    @PostConstruct
+    public void initialize() {
+        ThreadPoolExecutor threadPoolExecutor = ThreadPoolFactory.createConsumeThreadPoolExecutor(rocketProperties);
+
+        applicationContext.getBeansWithAnnotation(RocketListener.class).forEach((beanName, bean) -> {
+            RocketListener rocketListener = bean.getClass().getAnnotation(RocketListener.class);
+            AnnotatedMethodsUtils.getMethodAndAnnotation(bean, MessageListener.class).
+                    forEach((method, consumerListener) -> {
+                        ConsumerFactoryExecution consumerFactoryExecution = new ConsumerFactoryExecution(rocketProperties,
+                                rocketListener, consumerListener, new MethodFactoryExecution(bean, method, mqSerializer));
+                        ThreadPoolExecutorExecution.statsThread(threadPoolExecutor, consumerFactoryExecution);
+                    });
+        });
+
+        threadPoolExecutor.shutdown();
+    }
+
+    @Override
+    public void setApplicationContext(@NonNull ApplicationContext applicationContext) {
+        this.applicationContext = applicationContext;
+    }
+}

+ 64 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/container/RocketProducerContainer.java

@@ -0,0 +1,64 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.container;
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.core.factory.ThreadPoolFactory;
+import cc.uncarbon.framework.rocketmq.core.strategy.RocketConsumerStrategy;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import lombok.NonNull;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import javax.annotation.PostConstruct;
+import java.util.Map;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * ClassName: RocketProducerContainer
+ * Description:
+ * date: 2019/5/3 11:29
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class RocketProducerContainer implements ApplicationContextAware {
+
+	private ApplicationContext applicationContext;
+
+	private final AliyunRocketProperties rocketProperties;
+
+	private final Map<String, Object> consumerContainer;
+
+
+	public RocketProducerContainer(Map<String, Object> consumerContainer, AliyunRocketProperties rocketProperties) {
+		this.consumerContainer = consumerContainer;
+		this.rocketProperties = rocketProperties;
+	}
+
+	@PostConstruct
+	public void initialize() {
+		ThreadPoolExecutor threadPoolExecutor = ThreadPoolFactory.createProducerThreadPoolExecutor(rocketProperties);
+		applicationContext.getBeansWithAnnotation(RocketMessage.class).forEach((beanName, bean) -> RocketConsumerStrategy.putProducer(threadPoolExecutor, consumerContainer, bean, rocketProperties, applicationContext));
+		threadPoolExecutor.shutdown();
+	}
+
+	@Override
+	public void setApplicationContext(@NonNull ApplicationContext applicationContext) {
+		this.applicationContext = applicationContext;
+	}
+}

+ 47 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/consumer/AbstractRocketListener.java

@@ -0,0 +1,47 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.consumer;
+
+import cc.uncarbon.framework.rocketmq.core.factory.execution.MethodFactoryExecution;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * ClassName: AbstractRocketListener
+ * Description:
+ * date: 2019/4/27 17:07
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Data
+@Slf4j
+public abstract class AbstractRocketListener {
+    private MethodFactoryExecution methodFactoryExecution;
+
+    protected AbstractRocketListener(MethodFactoryExecution methodFactoryExecution) {
+        this.methodFactoryExecution = methodFactoryExecution;
+    }
+
+    public void printErrorLog() {
+        log.error("Consumer agent failed!bean:{},method:{}",
+                methodFactoryExecution.getBean(),
+                methodFactoryExecution.getMethod());
+    }
+
+
+}

+ 64 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/consumer/DefaultBatchMessageListener.java

@@ -0,0 +1,64 @@
+/**
+ * Copyright 2020 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.consumer;
+
+import cc.uncarbon.framework.rocketmq.core.factory.execution.MethodFactoryExecution;
+import cc.uncarbon.framework.rocketmq.exception.RocketException;
+import com.aliyun.openservices.ons.api.Action;
+import com.aliyun.openservices.ons.api.ConsumeContext;
+import com.aliyun.openservices.ons.api.Message;
+import com.aliyun.openservices.ons.api.batch.BatchMessageListener;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+
+/**
+ * ClassName: DefaultBatchMessageListener
+ * Description:
+ * date: 2020/12/8 9:08
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Slf4j
+public class DefaultBatchMessageListener extends AbstractRocketListener implements BatchMessageListener {
+    public DefaultBatchMessageListener(MethodFactoryExecution methodFactoryExecution) {
+        super(methodFactoryExecution);
+    }
+
+    /**
+     * 批量消费消息接口,由应用来实现<br>
+     * 需要注意网络抖动等不稳定的情形可能会带来消息重复,对重复消息敏感的业务可对消息做幂等处理
+     *
+     * @param messages 一批消息
+     * @param context  消费上下文
+     * @return {@link Action} 消费结果,如果应用抛出异常或者返回Null等价于返回Action.ReconsumeLater
+     * @see <a href="https://help.aliyun.com/document_detail/44397.html">如何做到消费幂等</a>
+     */
+    @Override
+    public Action consume(List<Message> messages, ConsumeContext context) {
+        log.info(">>>>messageList:{}>>>>", messages);
+        try {
+            for (Message message : messages) {
+                super.getMethodFactoryExecution().methodExecution(message.getBody());
+            }
+        } catch (RocketException e) {
+            super.printErrorLog();
+            return Action.ReconsumeLater;
+        }
+        return Action.CommitMessage;
+    }
+}

+ 62 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/consumer/DefaultMessageListener.java

@@ -0,0 +1,62 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.consumer;
+
+import cc.uncarbon.framework.rocketmq.core.factory.execution.MethodFactoryExecution;
+import cc.uncarbon.framework.rocketmq.exception.RocketException;
+import com.aliyun.openservices.ons.api.Action;
+import com.aliyun.openservices.ons.api.ConsumeContext;
+import com.aliyun.openservices.ons.api.Message;
+import com.aliyun.openservices.ons.api.MessageListener;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * ClassName: DefaultMessageListener
+ * Description:
+ * date: 2019/4/27 17:05
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Slf4j
+public class DefaultMessageListener extends AbstractRocketListener implements MessageListener {
+
+    public DefaultMessageListener(MethodFactoryExecution methodFactoryExecution) {
+        super (methodFactoryExecution);
+    }
+
+    /**
+     * 消费消息接口,由应用来实现<br>
+     * 网络抖动等不稳定的情形可能会带来消息重复,对重复消息敏感的业务可对消息做幂等处理
+     *
+     * @param message 消息
+     * @param context 消费上下文
+     * @return 消费结果,如果应用抛出异常或者返回Null等价于返回Action.ReconsumeLater
+     * @see <a href="https://help.aliyun.com/document_detail/44397.html">如何做到消费幂等</a>
+     */
+    @Override
+    public Action consume(Message message, ConsumeContext context) {
+        log.info (">>>>message:{}>>>>", message);
+        try {
+            super.getMethodFactoryExecution ().methodExecution (message.getBody ());
+        } catch (RocketException e) {
+            super.printErrorLog ();
+            return Action.ReconsumeLater;
+        }
+        return Action.CommitMessage;
+    }
+}

+ 64 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/consumer/DefaultMessageOrderListener.java

@@ -0,0 +1,64 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.consumer;
+
+import cc.uncarbon.framework.rocketmq.core.factory.execution.MethodFactoryExecution;
+import cc.uncarbon.framework.rocketmq.exception.RocketException;
+import com.aliyun.openservices.ons.api.Message;
+import com.aliyun.openservices.ons.api.order.ConsumeOrderContext;
+import com.aliyun.openservices.ons.api.order.MessageOrderListener;
+import com.aliyun.openservices.ons.api.order.OrderAction;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * ClassName: DefaultMessageOrderListener
+ * Description:
+ * date: 2019/4/26 23:16
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+
+@Slf4j
+public class DefaultMessageOrderListener extends AbstractRocketListener implements MessageOrderListener {
+
+
+    public DefaultMessageOrderListener(MethodFactoryExecution methodFactoryExecution) {
+        super (methodFactoryExecution);
+    }
+
+    /**
+     * 消费消息接口,由应用来实现<br>
+     * 需要注意网络抖动等不稳定的情形可能会带来消息重复,对重复消息敏感的业务可对消息做幂等处理
+     *
+     * @param message 消息
+     * @param context 消费上下文
+     * @return {@link OrderAction} 消费结果,如果应用抛出异常或者返回Null等价于返回Action.ReconsumeLater
+     * @see <a href="https://help.aliyun.com/document_detail/44397.html">如何做到消费幂等</a>
+     */
+    @Override
+    public OrderAction consume(Message message, ConsumeOrderContext context) {
+        log.info (">>>> Order message:{}>>>>", message);
+        try {
+            super.getMethodFactoryExecution ().methodExecution (message.getBody ());
+        } catch (RocketException e) {
+            super.printErrorLog ();
+            return OrderAction.Suspend;
+        }
+        return OrderAction.Success;
+    }
+}

+ 51 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ConsumerFactory.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import com.aliyun.openservices.ons.api.Consumer;
+import com.aliyun.openservices.ons.api.ONSFactory;
+import com.aliyun.openservices.ons.api.batch.BatchConsumer;
+import com.aliyun.openservices.ons.api.order.OrderConsumer;
+
+import java.util.Properties;
+
+
+/**
+ * ClassName: ConsumerFactory
+ * Description:
+ * date: 2019/4/27 15:55
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ConsumerFactory {
+	private ConsumerFactory() {
+	}
+
+	public static Consumer createConsumer(Properties properties) {
+		return ONSFactory.createConsumer(properties);
+	}
+
+
+	public static OrderConsumer createOrderConsumer(Properties properties) {
+		return ONSFactory.createOrderedConsumer(properties);
+	}
+
+	public static BatchConsumer createBatchConsumer(Properties properties) {
+		return ONSFactory.createBatchConsumer(properties);
+	}
+}

+ 52 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ConsumerPropertiesFactory.java

@@ -0,0 +1,52 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketListener;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import com.aliyun.openservices.ons.api.PropertyKeyConst;
+
+import java.util.Properties;
+
+/**
+ * ClassName: ConsumerPropertiesFactory
+ * Description:
+ * date: 2019/4/27 15:37
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ConsumerPropertiesFactory {
+	private ConsumerPropertiesFactory() {
+	}
+
+	public static Properties createConsumerProperties(AliyunRocketProperties rocketProperties,
+													  RocketListener rocketListener) {
+
+		Properties properties = PropertiesFactory.createProperties(rocketProperties);
+
+		properties.put(PropertyKeyConst.GROUP_ID, rocketListener.groupID());
+		properties.put(PropertyKeyConst.MessageModel, rocketListener.messageModel());
+		properties.put(PropertyKeyConst.ConsumeThreadNums, rocketProperties.getConsumeThreadNums());
+		properties.put(PropertyKeyConst.MaxReconsumeTimes, rocketProperties.getMaxReconsumeTimes());
+		properties.put(PropertyKeyConst.ConsumeTimeout, rocketProperties.getConsumeTimeout());
+
+
+		return properties;
+
+	}
+}

+ 53 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/MessageFactory.java

@@ -0,0 +1,53 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.annotation.CommonMessage;
+import cc.uncarbon.framework.rocketmq.annotation.OrderMessage;
+import cc.uncarbon.framework.rocketmq.annotation.TransactionMessage;
+import com.aliyun.openservices.ons.api.Message;
+
+/**
+ * ClassName: MessageFactory
+ * Description:
+ * date: 2019/4/28 21:55
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class MessageFactory {
+	private MessageFactory() {
+	}
+
+	public static Message createMessage(CommonMessage commonMessage, byte[] body) {
+		return new Message(commonMessage.topic(),
+				commonMessage.tag(),
+				body);
+	}
+
+	public static Message createMessage(OrderMessage orderMessage, byte[] body) {
+		return new Message(orderMessage.topic(),
+				orderMessage.tag(),
+				body);
+	}
+
+	public static Message createMessage(TransactionMessage transactionMessage, byte[] body) {
+		return new Message(transactionMessage.topic(),
+				transactionMessage.tag(),
+				body);
+	}
+}

+ 37 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/MethodFactory.java

@@ -0,0 +1,37 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import java.lang.reflect.Method;
+
+/**
+ * ClassName: MethodFactory
+ * Description:
+ * date: 2019/4/27 16:13
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+
+public class MethodFactory {
+	private MethodFactory() {
+	}
+
+	public static Class<?> getMethodParameter(Method method) {
+		return method.getParameterTypes()[0];
+	}
+}

+ 73 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ProducerConsumerFactory.java

@@ -0,0 +1,73 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.annotation.CommonMessage;
+import cc.uncarbon.framework.rocketmq.annotation.OrderMessage;
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.annotation.TransactionMessage;
+import com.aliyun.openservices.ons.api.Producer;
+import com.aliyun.openservices.ons.api.order.OrderProducer;
+import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
+
+import java.util.Map;
+
+/**
+ * ClassName: ProducerConsumerFactory
+ * Description:
+ * date: 2019/5/3 13:45
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ProducerConsumerFactory {
+	private ProducerConsumerFactory() {
+	}
+
+	public static String getProducerConsumerKey(RocketMessage rocketMessage, CommonMessage commonMessage) {
+		return rocketMessage.groupID() +
+				commonMessage.topic() +
+				commonMessage.tag();
+	}
+
+	public static String getProducerConsumerKey(RocketMessage rocketMessage, OrderMessage orderMessage) {
+		return rocketMessage.groupID() +
+				orderMessage.topic() +
+				orderMessage.tag();
+	}
+
+	public static String getProducerConsumerKey(RocketMessage rocketMessage, TransactionMessage transactionMessage) {
+		return rocketMessage.groupID() +
+				transactionMessage.topic() +
+				transactionMessage.tag();
+	}
+
+	public static Producer getProducer(Map<String, Object> consumerContainer, RocketMessage rocketMessage, CommonMessage commonMessage){
+		String producerConsumerKey = cc.uncarbon.framework.rocketmq.core.factory.ProducerConsumerFactory.getProducerConsumerKey(rocketMessage, commonMessage);
+		return (Producer) consumerContainer.get(producerConsumerKey);
+	}
+
+	public static OrderProducer getProducer(Map<String, Object> consumerContainer, RocketMessage rocketMessage, OrderMessage orderMessage){
+		String producerConsumerKey = cc.uncarbon.framework.rocketmq.core.factory.ProducerConsumerFactory.getProducerConsumerKey(rocketMessage, orderMessage);
+		return (OrderProducer) consumerContainer.get(producerConsumerKey);
+	}
+
+	public static TransactionProducer getProducer(Map<String, Object> consumerContainer, RocketMessage rocketMessage, TransactionMessage transactionMessage){
+		String producerConsumerKey = cc.uncarbon.framework.rocketmq.core.factory.ProducerConsumerFactory.getProducerConsumerKey(rocketMessage, transactionMessage);
+		return (TransactionProducer) consumerContainer.get(producerConsumerKey);
+	}
+}

+ 57 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ProducerFactory.java

@@ -0,0 +1,57 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import com.aliyun.openservices.ons.api.ONSFactory;
+import com.aliyun.openservices.ons.api.Producer;
+import com.aliyun.openservices.ons.api.PropertyKeyConst;
+import com.aliyun.openservices.ons.api.order.OrderProducer;
+import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker;
+import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
+
+import java.util.Properties;
+
+/**
+ * ClassName: ProducerFactory
+ * Description:
+ * date: 2019/4/28 21:35
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ProducerFactory {
+	private ProducerFactory() {
+	}
+
+	public static Producer createProducer(RocketMessage rocketMessage, AliyunRocketProperties rocketProperties) {
+		Properties properties = ProducerPropertiesFactory.createProducerProperties(rocketMessage, rocketProperties);
+		return ONSFactory.createProducer(properties);
+	}
+
+	public static OrderProducer createOrderProducer(RocketMessage rocketMessage, AliyunRocketProperties rocketProperties) {
+		Properties properties = ProducerPropertiesFactory.createProducerProperties(rocketMessage, rocketProperties);
+		return ONSFactory.createOrderProducer(properties);
+	}
+
+	public static TransactionProducer createTransactionProducer(RocketMessage rocketMessage, AliyunRocketProperties rocketProperties, LocalTransactionChecker localTransactionChecker) {
+		Properties properties = ProducerPropertiesFactory.createProducerProperties(rocketMessage, rocketProperties);
+		properties.put(PropertyKeyConst.CheckImmunityTimeInSeconds, rocketProperties.getCheckImmunityTimeInSeconds());
+		return ONSFactory.createTransactionProducer(properties, localTransactionChecker);
+	}
+}

+ 44 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ProducerPropertiesFactory.java

@@ -0,0 +1,44 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import com.aliyun.openservices.ons.api.PropertyKeyConst;
+
+import java.util.Properties;
+
+/**
+ * ClassName: ProducerPropertiesFactory
+ * Description:
+ * date: 2019/4/28 21:21
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ProducerPropertiesFactory {
+	private ProducerPropertiesFactory() {
+	}
+
+	public static Properties createProducerProperties(RocketMessage rockerMessage, AliyunRocketProperties rocketProperties) {
+		Properties properties = PropertiesFactory.createProperties(rocketProperties);
+		properties.put(PropertyKeyConst.SendMsgTimeoutMillis, rocketProperties.getSendMsgTimeoutMillis());
+		properties.put(PropertyKeyConst.GROUP_ID, rockerMessage.groupID());
+		return properties;
+	}
+
+}

+ 45 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/PropertiesFactory.java

@@ -0,0 +1,45 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import com.aliyun.openservices.ons.api.PropertyKeyConst;
+
+import java.util.Properties;
+
+/**
+ * ClassName: PropertiesFactory
+ * Description:
+ * date: 2019/4/27 20:26
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class PropertiesFactory {
+	private PropertiesFactory() {
+	}
+
+	public static Properties createProperties(AliyunRocketProperties rocketProperties) {
+		Properties properties = new Properties();
+		properties.put(PropertyKeyConst.NAMESRV_ADDR, rocketProperties.getNameSrvAddr());
+		properties.put(PropertyKeyConst.AccessKey, rocketProperties.getAccessKey());
+		properties.put(PropertyKeyConst.SecretKey, rocketProperties.getSecretKey());
+		properties.put(PropertyKeyConst.OnsChannel, rocketProperties.getOnsChannel());
+
+		return properties;
+	}
+}

+ 60 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/SendMessageFactory.java

@@ -0,0 +1,60 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.annotation.CommonMessage;
+import cc.uncarbon.framework.rocketmq.annotation.OrderMessage;
+import cc.uncarbon.framework.rocketmq.annotation.TransactionMessage;
+import cc.uncarbon.framework.rocketmq.core.strategy.SendMessageStrategy;
+import cc.uncarbon.framework.rocketmq.core.utils.ApplicationContextUtils;
+import com.aliyun.openservices.ons.api.Message;
+import com.aliyun.openservices.ons.api.Producer;
+import com.aliyun.openservices.ons.api.order.OrderProducer;
+import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
+import org.springframework.context.ApplicationContext;
+
+
+/**
+ * ClassName: SendMessageFactory
+ * Description:
+ * date: 2019/4/29 21:52
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class SendMessageFactory {
+    private SendMessageFactory() {
+    }
+
+    public static void sendMessage(Long startDeliverTime, Producer producer, CommonMessage commonMessage, byte[] bytes, ApplicationContext applicationContext) {
+        Message message = MessageFactory.createMessage(commonMessage, bytes);
+        if (null != startDeliverTime) {
+            message.setStartDeliverTime(startDeliverTime);
+        }
+        SendMessageStrategy.send(commonMessage, producer, message, applicationContext);
+    }
+
+    public static void sendMessage(OrderProducer orderProducer, OrderMessage orderMessage, byte[] bytes, String shardingKeyFactory) {
+        Message message = MessageFactory.createMessage(orderMessage, bytes);
+        orderProducer.send(message, shardingKeyFactory);
+    }
+
+    public static void sendMessage(TransactionProducer transactionProducer, TransactionMessage transactionMessage, byte[] bytes, ApplicationContext applicationContext) {
+        Message message = MessageFactory.createMessage(transactionMessage, bytes);
+        transactionProducer.send(message, ApplicationContextUtils.getLocalTransactionExecuter(applicationContext, transactionMessage.executor()), null);
+    }
+}

+ 44 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ShardingKeyFactory.java

@@ -0,0 +1,44 @@
+/**
+ * Copyright 2021 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.annotation.ShardingKey;
+import cn.hutool.core.util.ObjectUtil;
+
+import java.lang.reflect.Parameter;
+
+/**
+ * Classname: ShardingKeyFactory
+ * Description:
+ * Date: 2021/11/3 20:00
+ *
+ * @author ThierrySquirrel
+ * @since JDK 11
+ */
+public class ShardingKeyFactory {
+    private ShardingKeyFactory() {
+    }
+
+    public static String getShardingKeyFactory(Object[] args, Parameter[] params) {
+        for (int i = 0; i < args.length; i++) {
+            ShardingKey annotation = params[i].getAnnotation(ShardingKey.class);
+            if (ObjectUtil.isNotEmpty(annotation)) {
+                return (String) args[i];
+            }
+        }
+        return null;
+    }
+}

+ 46 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/StartDeliverTimeFactory.java

@@ -0,0 +1,46 @@
+/**
+ * Copyright 2020 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.annotation.StartDeliverTime;
+import cn.hutool.core.util.ObjectUtil;
+
+import java.lang.reflect.Parameter;
+
+/**
+ * ClassName: StartDeliverTimeFactory
+ * Description:
+ * date: 2020/1/29 19:07
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class StartDeliverTimeFactory {
+
+    private StartDeliverTimeFactory() {
+    }
+
+    public static Long getStartDeliverTime(Object[] args, Parameter[] params) {
+        for (int i = 0; i < args.length; i++) {
+            StartDeliverTime annotation = params[i].getAnnotation(StartDeliverTime.class);
+            if (ObjectUtil.isNotEmpty(annotation)) {
+                return (Long) args[i];
+            }
+        }
+        return null;
+    }
+}

+ 104 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/ThreadPoolFactory.java

@@ -0,0 +1,104 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory;
+
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import com.aliyun.openservices.shade.com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * ClassName: ThreadPoolFactory
+ * Description:
+ * date: 2019/4/27 19:52
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ThreadPoolFactory {
+    private ThreadPoolFactory() {
+    }
+
+    public static ThreadPoolExecutor createConsumeThreadPoolExecutor(AliyunRocketProperties rocketProperties) {
+        Integer threadNums = rocketProperties.getCreateConsumeThreadNums();
+
+        ThreadFactory threadFactory = new ThreadFactoryBuilder()
+                .setNameFormat("InitializeConsumerListener").build();
+
+        return new ThreadPoolExecutor(threadNums,
+                threadNums,
+                0,
+                TimeUnit.SECONDS,
+                new LinkedBlockingQueue<>(1024),
+                threadFactory,
+                new ThreadPoolExecutor.AbortPolicy()
+        );
+    }
+
+    public static ThreadPoolExecutor createProducerThreadPoolExecutor(AliyunRocketProperties rocketProperties) {
+
+        Integer threadNums = rocketProperties.getCreateProducerThreadNums();
+
+        ThreadFactory threadFactory = new ThreadFactoryBuilder()
+                .setNameFormat("InitializeProducer").build();
+
+        return new ThreadPoolExecutor(threadNums,
+                threadNums,
+                0,
+                TimeUnit.SECONDS,
+                new LinkedBlockingQueue<>(1024),
+                threadFactory,
+                new ThreadPoolExecutor.AbortPolicy()
+        );
+    }
+
+    public static ThreadPoolExecutor createSendMessageThreadPoolExecutor(AliyunRocketProperties rocketProperties) {
+
+        Integer threadNums = rocketProperties.getSendMessageThreadNums();
+
+        ThreadFactory threadFactory = new ThreadFactoryBuilder()
+                .setNameFormat("SendMessage").build();
+
+        return new ThreadPoolExecutor(threadNums,
+                threadNums,
+                0,
+                TimeUnit.SECONDS,
+                new LinkedBlockingQueue<>(),
+                threadFactory,
+                new ThreadPoolExecutor.AbortPolicy()
+        );
+    }
+
+    public static ThreadPoolExecutor createCallbackThreadPoolExecutor(AliyunRocketProperties rocketProperties) {
+
+        Integer threadNums = rocketProperties.getCallbackThreadNums();
+
+        ThreadFactory threadFactory = new ThreadFactoryBuilder()
+                .setNameFormat("callback").build();
+        return new ThreadPoolExecutor(threadNums,
+                threadNums,
+                0,
+                TimeUnit.SECONDS,
+                new LinkedBlockingQueue<>(),
+                threadFactory,
+                new ThreadPoolExecutor.AbortPolicy()
+        );
+    }
+}

+ 77 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/ConsumerFactoryExecution.java

@@ -0,0 +1,77 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory.execution;
+
+import cc.uncarbon.framework.rocketmq.annotation.MessageListener;
+import cc.uncarbon.framework.rocketmq.annotation.RocketListener;
+import cc.uncarbon.framework.rocketmq.core.consumer.DefaultBatchMessageListener;
+import cc.uncarbon.framework.rocketmq.core.consumer.DefaultMessageListener;
+import cc.uncarbon.framework.rocketmq.core.consumer.DefaultMessageOrderListener;
+import cc.uncarbon.framework.rocketmq.core.factory.ConsumerFactory;
+import cc.uncarbon.framework.rocketmq.core.factory.ConsumerPropertiesFactory;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import cc.uncarbon.framework.rocketmq.thread.AbstractConsumerThread;
+import com.aliyun.openservices.ons.api.Consumer;
+import com.aliyun.openservices.ons.api.PropertyKeyConst;
+import com.aliyun.openservices.ons.api.batch.BatchConsumer;
+import com.aliyun.openservices.ons.api.order.OrderConsumer;
+
+import java.util.Properties;
+
+/**
+ * ClassName: ConsumerFactoryExecution
+ * Description:
+ * date: 2019/4/27 16:05
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ConsumerFactoryExecution extends AbstractConsumerThread {
+
+
+    public ConsumerFactoryExecution(AliyunRocketProperties rocketProperties, RocketListener rocketListener, MessageListener consumerListener, MethodFactoryExecution methodFactoryExecution) {
+        super(rocketProperties, rocketListener, consumerListener, methodFactoryExecution);
+    }
+
+    @Override
+    public void statsConsumer(AliyunRocketProperties rocketProperties,
+                              RocketListener rocketListener,
+                              MessageListener consumerListener,
+                              MethodFactoryExecution methodFactoryExecution) {
+
+        Properties properties = ConsumerPropertiesFactory.createConsumerProperties(rocketProperties, rocketListener);
+        if (consumerListener.orderConsumer()) {
+            properties.put(PropertyKeyConst.SuspendTimeMillis, rocketProperties.getSuspendTimeMilli());
+            OrderConsumer orderConsumer = ConsumerFactory.createOrderConsumer(properties);
+            orderConsumer.subscribe(consumerListener.topic(), consumerListener.tag(), new DefaultMessageOrderListener(methodFactoryExecution));
+            orderConsumer.start();
+            return;
+        }
+        if (consumerListener.batchConsumer()) {
+            properties.put(PropertyKeyConst.ConsumeMessageBatchMaxSize, consumerListener.consumeMessageBatchMaxSize());
+            properties.put(PropertyKeyConst.BatchConsumeMaxAwaitDurationInSeconds, consumerListener.batchConsumeMaxAwaitDurationInSeconds());
+            BatchConsumer batchConsumer = ConsumerFactory.createBatchConsumer(properties);
+            batchConsumer.subscribe(consumerListener.topic(), consumerListener.tag(), new DefaultBatchMessageListener(methodFactoryExecution));
+            batchConsumer.start();
+            return;
+        }
+
+        Consumer consumer = ConsumerFactory.createConsumer(properties);
+        consumer.subscribe(consumerListener.topic(), consumerListener.tag(), new DefaultMessageListener(methodFactoryExecution));
+        consumer.start();
+    }
+}

+ 53 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/MethodFactoryExecution.java

@@ -0,0 +1,53 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory.execution;
+
+import cc.uncarbon.framework.rocketmq.core.factory.MethodFactory;
+import cc.uncarbon.framework.rocketmq.core.serializer.RocketSerializer;
+import cc.uncarbon.framework.rocketmq.exception.RocketException;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+import java.lang.reflect.Method;
+
+/**
+ * ClassName: MethodFactoryExecution
+ * Description:
+ * date: 2019/4/27 16:26
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Slf4j
+@AllArgsConstructor
+@Data
+public class MethodFactoryExecution {
+    private Object bean;
+    private Method method;
+    private RocketSerializer rocketSerializer;
+
+    public void methodExecution(byte[] message) throws RocketException {
+        try {
+            Class<?> methodParameter = MethodFactory.getMethodParameter(method);
+            Object methodParameterBean = rocketSerializer.deSerialize(message, methodParameter);
+            method.invoke(bean, methodParameterBean);
+        } catch (Exception e) {
+            throw new RocketException(e);
+        }
+    }
+}

+ 54 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/ProducerFactoryExecution.java

@@ -0,0 +1,54 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory.execution;
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.core.strategy.PutProducerStrategy;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import cc.uncarbon.framework.rocketmq.thread.AbstractProducerThread;
+import org.springframework.context.ApplicationContext;
+
+import java.util.Map;
+
+/**
+ * ClassName: ProducerFactoryExecution
+ * Description:
+ * date: 2019/5/3 13:25
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ProducerFactoryExecution extends AbstractProducerThread {
+
+	public ProducerFactoryExecution(Map<String, Object> producerConsumer, RocketMessage rocketMessage, Object bean, AliyunRocketProperties rocketProperties, ApplicationContext applicationContext) {
+		super(producerConsumer, rocketMessage, bean, rocketProperties, applicationContext);
+	}
+
+	/**
+	 * 开始向容器装填
+	 *
+	 * @param producerConsumer   producerConsumer
+	 * @param rocketMessage      rocketMessage
+	 * @param bean               bean
+	 * @param rocketProperties   rocketProperties
+	 * @param applicationContext applicationContext
+	 */
+	@Override
+	protected void statsPutProducer(Map<String, Object> producerConsumer, RocketMessage rocketMessage, Object bean, AliyunRocketProperties rocketProperties, ApplicationContext applicationContext) {
+		PutProducerStrategy.putProducer(producerConsumer, rocketMessage, bean, rocketProperties, applicationContext);
+	}
+}

+ 66 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/SendMessageFactoryExecution.java

@@ -0,0 +1,66 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory.execution;
+
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.core.strategy.ProducerStrategy;
+import cc.uncarbon.framework.rocketmq.exception.RocketException;
+import cc.uncarbon.framework.rocketmq.thread.AbstractSendMessageThread;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.ApplicationContext;
+
+import java.util.Map;
+
+
+/**
+ * ClassName: SendMessageFactoryExecution
+ * Description:
+ * date: 2019/4/28 21:31
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Slf4j
+public class SendMessageFactoryExecution extends AbstractSendMessageThread {
+
+
+    public SendMessageFactoryExecution(Long startDeliverTime, String shardingKeyFactory, Map<String, Object> consumerContainer, RocketMessage rocketMessage, Object message, byte[] bytes, ApplicationContext applicationContext) {
+        super(startDeliverTime, shardingKeyFactory, consumerContainer, rocketMessage, message, bytes, applicationContext);
+    }
+
+    /**
+     * 开始发送消息
+     *
+     * @param startDeliverTime   startDeliverTime
+     * @param shardingKeyFactory shardingKeyFactory
+     * @param consumerContainer  consumerContainer
+     * @param rocketMessage      rocketMessage
+     * @param message            message
+     * @param bytes              bytes
+     * @param applicationContext applicationContext
+     */
+    @Override
+    protected void statsSendMessage(Long startDeliverTime, String shardingKeyFactory, Map<String, Object> consumerContainer, RocketMessage rocketMessage, Object message, byte[] bytes, ApplicationContext applicationContext) {
+        try {
+            ProducerStrategy.statsSendMessage(startDeliverTime, shardingKeyFactory, consumerContainer, rocketMessage, message, bytes, applicationContext);
+        } catch (RocketException e) {
+            log.error("statsSendMessage Error", e);
+        }
+    }
+}
+

+ 37 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/factory/execution/ThreadPoolExecutorExecution.java

@@ -0,0 +1,37 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.factory.execution;
+
+import lombok.experimental.UtilityClass;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * ClassName: ThreadPoolExecutorExecution
+ * Description:
+ * date: 2019/4/27 19:55
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@UtilityClass
+public class ThreadPoolExecutorExecution {
+
+	public static void statsThread(ThreadPoolExecutor threadPoolExecutor, Runnable runnable) {
+		threadPoolExecutor.execute(runnable);
+	}
+}

+ 51 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/producer/DefaultLocalTransactionChecker.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.producer;
+
+import com.aliyun.openservices.ons.api.Message;
+import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker;
+import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * ClassName: DefaultLocalTransactionChecker
+ * Description:
+ * date: 2019/4/28 21:42
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Slf4j
+@AllArgsConstructor
+@Data
+public class DefaultLocalTransactionChecker implements LocalTransactionChecker {
+	private TransactionStatus transactionStatus;
+
+	/**
+	 * 回查本地事务,Broker回调Producer,将未结束的事务发给Producer,由Producer来再次决定事务是提交还是回滚
+	 *
+	 * @param msg 消息
+	 * @return {@link TransactionStatus} 事务状态, 包含提交事务、回滚事务、未知状态
+	 */
+	@Override
+	public TransactionStatus check(Message msg) {
+		log.info(">>>> Review local transactions message:{}>>>>", msg);
+		return transactionStatus;
+	}
+}

+ 46 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/producer/DefaultLocalTransactionExecutor.java

@@ -0,0 +1,46 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.producer;
+
+import com.aliyun.openservices.ons.api.Message;
+import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
+import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * ClassName: DefaultLocalTransactionExecuter
+ * Description:
+ * date: 2019/4/28 22:28
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Slf4j
+public class DefaultLocalTransactionExecutor implements LocalTransactionExecuter {
+	/**
+	 * 执行本地事务,由应用来重写
+	 *
+	 * @param msg 消息
+	 * @param arg 应用自定义参数,由send方法传入并回调
+	 * @return {@link TransactionStatus} 返回事务执行结果,包括提交事务、回滚事务、未知状态
+	 */
+	@Override
+	public TransactionStatus execute(Message msg, Object arg) {
+		log.info(">>>> Execute local transaction message:{}>>>>", msg);
+		return TransactionStatus.CommitTransaction;
+	}
+}

+ 53 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/producer/DefaultSendCallback.java

@@ -0,0 +1,53 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.producer;
+
+import com.aliyun.openservices.ons.api.OnExceptionContext;
+import com.aliyun.openservices.ons.api.SendCallback;
+import com.aliyun.openservices.ons.api.SendResult;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * ClassName: DefaultSendCallback
+ * Description:
+ * date: 2019/4/29 23:32
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Slf4j
+public class DefaultSendCallback implements SendCallback {
+    /**
+     * 发送成功回调的方法.
+     *
+     * @param sendResult 发送结果
+     */
+    @Override
+    public void onSuccess(SendResult sendResult) {
+        log.info("Message sent successfully. >> sendResult = {}", sendResult);
+    }
+
+    /**
+     * 发送失败回调方法.
+     *
+     * @param context 失败上下文.
+     */
+    @Override
+    public void onException(OnExceptionContext context) {
+        log.error("Failed to send message. >> topic = {}, messageId = {}, exception ", context.getTopic(), context.getMessageId(), context.getException());
+    }
+}

+ 41 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/producer/MessageSendType.java

@@ -0,0 +1,41 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.producer;
+
+/**
+ * ClassName: MessageSendType
+ * Description:
+ * date: 2019/4/28 21:02
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public enum MessageSendType {
+	/**
+	 * 同步发送
+	 */
+	SEND,
+	/**
+	 * 异步发送
+	 */
+	SEND_ASYNC,
+	/**
+	 * 单向发送
+	 */
+	SEND_ONE_WAY
+
+}

+ 32 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/serializer/Base64Serializer.java

@@ -0,0 +1,32 @@
+package cc.uncarbon.framework.rocketmq.core.serializer;
+
+import cn.hutool.core.codec.Base64;
+import cn.hutool.json.JSONUtil;
+
+import java.nio.charset.StandardCharsets;
+
+/**
+ * 基于 Hutool JSON 的 MQ Message 序列化器
+ *
+ * @author Uncarbon
+ */
+public class Base64Serializer implements RocketSerializer {
+
+    @Override
+    public <T> byte[] serialize(T object) {
+        if (object == null) {
+            return new byte[0];
+        }
+
+        return Base64.encode(JSONUtil.toJsonStr(object)).getBytes(StandardCharsets.UTF_8);
+    }
+
+    @Override
+    public <T> T deSerialize(byte[] bytes, Class<T> clazz) {
+        if (bytes.length == 0 || clazz == null) {
+            return null;
+        }
+
+        return JSONUtil.toBean(new String(Base64.decode(bytes)), clazz);
+    }
+}

+ 32 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/serializer/HutoolJsonSerializer.java

@@ -0,0 +1,32 @@
+package cc.uncarbon.framework.rocketmq.core.serializer;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
+
+import java.nio.charset.StandardCharsets;
+
+/**
+ * 基于 Hutool JSON 的 MQ Message 序列化器
+ *
+ * @author Uncarbon
+ */
+public class HutoolJsonSerializer implements RocketSerializer {
+
+    @Override
+    public <T> byte[] serialize(T object) {
+        if (object == null) {
+            return new byte[0];
+        }
+
+        return JSONUtil.toJsonStr(object).getBytes(StandardCharsets.UTF_8);
+    }
+
+    @Override
+    public <T> T deSerialize(byte[] bytes, Class<T> clazz) {
+        if (bytes.length == 0 || clazz == null) {
+            return null;
+        }
+
+        return JSONUtil.toBean(StrUtil.toString(bytes), clazz);
+    }
+}

+ 44 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/serializer/JacksonJsonSerializer.java

@@ -0,0 +1,44 @@
+package cc.uncarbon.framework.rocketmq.core.serializer;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+/**
+ * 基于 Jackson JSON 的 MQ Message 序列化器
+ *
+ * @author Uncarbon
+ */
+@Slf4j
+public class JacksonJsonSerializer implements RocketSerializer {
+
+    private final ObjectMapper objectMapper = new ObjectMapper();
+
+    @Override
+    public <T> byte[] serialize(T object) {
+        if (object != null) {
+            try {
+                return objectMapper.writeValueAsBytes(object);
+            } catch (JsonProcessingException jpe) {
+                log.error("[Rocket MQ-Aliyun][JacksonJsonSerializer] 序列化时发生异常 >> 堆栈", jpe);
+            }
+        }
+
+        return new byte[0];
+    }
+
+    @Override
+    public <T> T deSerialize(byte[] bytes, Class<T> clazz) {
+        if (bytes.length > 0 && clazz != null) {
+            try {
+                return objectMapper.readValue(bytes, clazz);
+            } catch (IOException e) {
+                log.error("[Rocket MQ-Aliyun][JacksonJsonSerializer] 反序列化时发生异常 >> 堆栈", e);
+            }
+        }
+
+        return null;
+    }
+}

+ 45 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/serializer/RocketSerializer.java

@@ -0,0 +1,45 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.serializer;
+
+/**
+ * ClassName: RocketSerializer
+ * Description:
+ * date: 2019/10/17 18:24
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public interface RocketSerializer {
+	/**
+	 * 序列化为byte[]
+	 * @param object 对象
+	 * @param <T> 泛型
+	 * @return 二进制数据
+	 */
+	<T> byte[] serialize(T object);
+
+	/**
+	 * byte[]反序列化为对象
+	 *
+	 * @param bytes 序列化的二进制数据
+	 * @param clazz 反序列化后的对象
+	 * @param <T>   T
+	 * @return 对象
+	 */
+	<T> T deSerialize(byte[] bytes, Class<T> clazz);
+}

+ 64 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/strategy/ProducerStrategy.java

@@ -0,0 +1,64 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.strategy;
+
+import cc.uncarbon.framework.rocketmq.annotation.CommonMessage;
+import cc.uncarbon.framework.rocketmq.annotation.OrderMessage;
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.annotation.TransactionMessage;
+import cc.uncarbon.framework.rocketmq.core.factory.ProducerConsumerFactory;
+import cc.uncarbon.framework.rocketmq.core.factory.SendMessageFactory;
+import cc.uncarbon.framework.rocketmq.exception.RocketException;
+import com.aliyun.openservices.ons.api.Producer;
+import com.aliyun.openservices.ons.api.order.OrderProducer;
+import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
+import org.springframework.context.ApplicationContext;
+
+import java.util.Map;
+
+/**
+ * ClassName: ProducerStrategy
+ * Description:
+ * date: 2019/4/29 21:34
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ProducerStrategy {
+    private ProducerStrategy() {
+    }
+
+    public static void statsSendMessage(Long startDeliverTime, String shardingKeyFactory, Map<String, Object> consumerContainer, RocketMessage rocketMessage, Object message, byte[] bytes, ApplicationContext applicationContext) throws RocketException {
+        if (message instanceof CommonMessage) {
+            CommonMessage commonMessage = (CommonMessage) message;
+            Producer producer = ProducerConsumerFactory.getProducer(consumerContainer, rocketMessage, commonMessage);
+            SendMessageFactory.sendMessage(startDeliverTime, producer, commonMessage, bytes, applicationContext);
+            return;
+        }
+        if (message instanceof OrderMessage) {
+            OrderMessage orderMessage = (OrderMessage) message;
+            OrderProducer orderProducer = ProducerConsumerFactory.getProducer(consumerContainer, rocketMessage, orderMessage);
+            SendMessageFactory.sendMessage(orderProducer, orderMessage, bytes, shardingKeyFactory);
+            return;
+        }
+        if (message instanceof TransactionMessage) {
+            TransactionMessage transactionMessage = (TransactionMessage) message;
+            TransactionProducer transactionProducer = ProducerConsumerFactory.getProducer(consumerContainer, rocketMessage, transactionMessage);
+            SendMessageFactory.sendMessage(transactionProducer, transactionMessage, bytes, applicationContext);
+        }
+    }
+}

+ 77 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/strategy/PutProducerStrategy.java

@@ -0,0 +1,77 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.strategy;
+
+import cc.uncarbon.framework.rocketmq.annotation.CommonMessage;
+import cc.uncarbon.framework.rocketmq.annotation.OrderMessage;
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.annotation.TransactionMessage;
+import cc.uncarbon.framework.rocketmq.core.factory.ProducerConsumerFactory;
+import cc.uncarbon.framework.rocketmq.core.factory.ProducerFactory;
+import cc.uncarbon.framework.rocketmq.core.factory.ThreadPoolFactory;
+import cc.uncarbon.framework.rocketmq.core.utils.ApplicationContextUtils;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import com.aliyun.openservices.ons.api.Producer;
+import com.aliyun.openservices.ons.api.order.OrderProducer;
+import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker;
+import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
+import org.springframework.context.ApplicationContext;
+
+import java.util.Map;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * ClassName: PutProducerStrategy
+ * Description:
+ * date: 2019/5/3 18:37
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class PutProducerStrategy {
+    private PutProducerStrategy() {
+    }
+
+    public static void putProducer(Map<String, Object> producerConsumer, RocketMessage rocketMessage, Object bean, AliyunRocketProperties rocketProperties, ApplicationContext applicationContext) {
+        if (bean instanceof CommonMessage) {
+            CommonMessage commonMessage = (CommonMessage) bean;
+            String producerConsumerKey = ProducerConsumerFactory.getProducerConsumerKey(rocketMessage, commonMessage);
+            Producer producer = ProducerFactory.createProducer(rocketMessage, rocketProperties);
+            ThreadPoolExecutor callbackThreadPoolExecutor = ThreadPoolFactory.createCallbackThreadPoolExecutor(rocketProperties);
+            producer.start();
+            producer.setCallbackExecutor(callbackThreadPoolExecutor);
+            producerConsumer.put(producerConsumerKey, producer);
+            return;
+        }
+        if (bean instanceof OrderMessage) {
+            OrderMessage orderMessage = (OrderMessage) bean;
+            String producerConsumerKey = ProducerConsumerFactory.getProducerConsumerKey(rocketMessage, orderMessage);
+            OrderProducer orderProducer = ProducerFactory.createOrderProducer(rocketMessage, rocketProperties);
+            orderProducer.start();
+            producerConsumer.put(producerConsumerKey, orderProducer);
+            return;
+        }
+        if (bean instanceof TransactionMessage) {
+            TransactionMessage transactionMessage = (TransactionMessage) bean;
+            String producerConsumerKey = ProducerConsumerFactory.getProducerConsumerKey(rocketMessage, transactionMessage);
+            LocalTransactionChecker localTransactionChecker = ApplicationContextUtils.getLocalTransactionChecker(applicationContext, transactionMessage.transactionStatus(), transactionMessage.checker());
+            TransactionProducer transactionProducer = ProducerFactory.createTransactionProducer(rocketMessage, rocketProperties, localTransactionChecker);
+            transactionProducer.start();
+            producerConsumer.put(producerConsumerKey, transactionProducer);
+        }
+    }
+}

+ 63 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/strategy/RocketConsumerStrategy.java

@@ -0,0 +1,63 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.strategy;
+
+import cc.uncarbon.framework.rocketmq.annotation.CommonMessage;
+import cc.uncarbon.framework.rocketmq.annotation.OrderMessage;
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.annotation.TransactionMessage;
+import cc.uncarbon.framework.rocketmq.core.factory.execution.ProducerFactoryExecution;
+import cc.uncarbon.framework.rocketmq.core.factory.execution.ThreadPoolExecutorExecution;
+import cc.uncarbon.framework.rocketmq.core.utils.AnnotatedMethodsUtils;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import org.springframework.context.ApplicationContext;
+
+import java.util.Map;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * ClassName: RocketConsumerStrategy
+ * Description:
+ * date: 2019/5/3 11:36
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+
+public class RocketConsumerStrategy {
+    private RocketConsumerStrategy() {
+    }
+
+    public static void putProducer(ThreadPoolExecutor threadPoolExecutor, Map<String, Object> producerConsumer, Object bean, AliyunRocketProperties rocketProperties, ApplicationContext applicationContext) {
+        RocketMessage rocketMessage = bean.getClass().getAnnotation(RocketMessage.class);
+        AnnotatedMethodsUtils.getMethodAndAnnotation(bean, CommonMessage.class).
+                forEach((method, commonMessage) -> {
+                    ProducerFactoryExecution producerFactoryExecution = new ProducerFactoryExecution(producerConsumer, rocketMessage, commonMessage, rocketProperties, applicationContext);
+                    ThreadPoolExecutorExecution.statsThread(threadPoolExecutor, producerFactoryExecution);
+                });
+        AnnotatedMethodsUtils.getMethodAndAnnotation(bean, OrderMessage.class).
+                forEach((method, orderMessage) -> {
+                    ProducerFactoryExecution producerFactoryExecution = new ProducerFactoryExecution(producerConsumer, rocketMessage, orderMessage, rocketProperties, applicationContext);
+                    ThreadPoolExecutorExecution.statsThread(threadPoolExecutor, producerFactoryExecution);
+                });
+        AnnotatedMethodsUtils.getMethodAndAnnotation(bean, TransactionMessage.class).
+                forEach((method, transactionMessage) -> {
+                    ProducerFactoryExecution producerFactoryExecution = new ProducerFactoryExecution(producerConsumer, rocketMessage, transactionMessage, rocketProperties, applicationContext);
+                    ThreadPoolExecutorExecution.statsThread(threadPoolExecutor, producerFactoryExecution);
+                });
+    }
+}

+ 52 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/strategy/SendMessageStrategy.java

@@ -0,0 +1,52 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.strategy;
+
+import cc.uncarbon.framework.rocketmq.annotation.CommonMessage;
+import cc.uncarbon.framework.rocketmq.core.producer.MessageSendType;
+import cc.uncarbon.framework.rocketmq.core.utils.ApplicationContextUtils;
+import com.aliyun.openservices.ons.api.Message;
+import com.aliyun.openservices.ons.api.Producer;
+import org.springframework.context.ApplicationContext;
+
+
+/**
+ * ClassName: SendMessageStrategy
+ * Description:
+ * date: 2019/4/29 23:37
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class SendMessageStrategy {
+	private SendMessageStrategy() {
+	}
+
+	public static void send(CommonMessage commonMessage, Producer producer, Message message, ApplicationContext applicationContext) {
+		if (commonMessage.messageSendType().equals(MessageSendType.SEND)) {
+			producer.send(message);
+			return;
+		}
+		if (commonMessage.messageSendType().equals(MessageSendType.SEND_ASYNC)) {
+			producer.sendAsync(message, ApplicationContextUtils.getSendCallback(applicationContext, commonMessage.callback()));
+			return;
+		}
+		if (commonMessage.messageSendType().equals(MessageSendType.SEND_ONE_WAY)) {
+			producer.sendOneway(message);
+		}
+	}
+}

+ 43 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/utils/AnnotatedMethodsUtils.java

@@ -0,0 +1,43 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.utils;
+
+import org.springframework.core.MethodIntrospector;
+import org.springframework.core.annotation.AnnotatedElementUtils;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+/**
+ * ClassName: AnnotatedMethodsUtils
+ * Description:
+ * date: 2019/5/3 11:44
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class AnnotatedMethodsUtils {
+	private AnnotatedMethodsUtils() {
+	}
+
+	public static <T extends Annotation> Map<Method, T> getMethodAndAnnotation(Object bean, Class<T> annotation) {
+		return MethodIntrospector.selectMethods(bean.getClass(),
+				(MethodIntrospector.MetadataLookup<T>) method -> AnnotatedElementUtils
+						.findMergedAnnotation(method, annotation));
+	}
+}

+ 69 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/utils/ApplicationContextUtils.java

@@ -0,0 +1,69 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.utils;
+
+import cc.uncarbon.framework.rocketmq.core.producer.DefaultLocalTransactionChecker;
+import cc.uncarbon.framework.rocketmq.core.producer.DefaultLocalTransactionExecutor;
+import cc.uncarbon.framework.rocketmq.core.producer.DefaultSendCallback;
+import com.aliyun.openservices.ons.api.SendCallback;
+import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker;
+import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
+import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * ClassName: ApplicationContextUtils
+ * Description:
+ * date: 2019/7/11 18:47
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class ApplicationContextUtils {
+	private ApplicationContextUtils() {
+	}
+
+	public static SendCallback getSendCallback(ApplicationContext applicationContext, Class<? extends SendCallback> callback) {
+		SendCallback sendCallback;
+		if (DefaultSendCallback.class.equals(callback)) {
+			sendCallback = new DefaultSendCallback();
+		} else {
+			sendCallback = applicationContext.getBean(callback);
+		}
+		return sendCallback;
+	}
+
+	public static LocalTransactionChecker getLocalTransactionChecker(ApplicationContext applicationContext, TransactionStatus transactionStatus, Class<? extends LocalTransactionChecker> checker) {
+		LocalTransactionChecker localTransactionChecker;
+		if (DefaultLocalTransactionChecker.class.equals(checker)) {
+			localTransactionChecker = new DefaultLocalTransactionChecker(transactionStatus);
+		} else {
+			localTransactionChecker = applicationContext.getBean(checker);
+		}
+		return localTransactionChecker;
+	}
+
+	public static LocalTransactionExecuter getLocalTransactionExecuter(ApplicationContext applicationContext, Class<? extends LocalTransactionExecuter> executer) {
+		LocalTransactionExecuter localTransactionExecuter;
+		if (DefaultLocalTransactionExecutor.class.equals(executer)) {
+			localTransactionExecuter = new DefaultLocalTransactionExecutor();
+		} else {
+			localTransactionExecuter = applicationContext.getBean(executer);
+		}
+		return localTransactionExecuter;
+	}
+}

+ 55 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/utils/AspectUtils.java

@@ -0,0 +1,55 @@
+/**
+ * Copyright 2020 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.utils;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.reflect.MethodSignature;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+
+/**
+ * ClassName: AspectUtils
+ * Description:
+ * date: 2020/1/29 18:49
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class AspectUtils {
+	private AspectUtils() {
+	}
+
+	private static Method getMethod(ProceedingJoinPoint proceedingJoinPoint) {
+		MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature();
+		return signature.getMethod();
+	}
+
+	public static <T extends Annotation> T getAnnotation(ProceedingJoinPoint proceedingJoinPoint, Class<T> annotationClass) {
+		return getMethod(proceedingJoinPoint).getAnnotation(annotationClass);
+	}
+
+	public static <T extends Annotation> T getDeclaringClassAnnotation(ProceedingJoinPoint proceedingJoinPoint, Class<T> annotationClass) {
+		return getMethod(proceedingJoinPoint).getDeclaringClass().getAnnotation(annotationClass);
+	}
+
+	public static Parameter[] getParams(ProceedingJoinPoint proceedingJoinPoint) {
+		Method method = getMethod(proceedingJoinPoint);
+		return method.getParameters();
+	}
+}

+ 48 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/core/utils/InterceptRocket.java

@@ -0,0 +1,48 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.core.utils;
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.core.factory.execution.SendMessageFactoryExecution;
+import cc.uncarbon.framework.rocketmq.core.factory.execution.ThreadPoolExecutorExecution;
+import cc.uncarbon.framework.rocketmq.core.serializer.RocketSerializer;
+import org.springframework.context.ApplicationContext;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * ClassName: InterceptRocket
+ * Description:
+ * date: 2019/4/29 22:03
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class InterceptRocket {
+    private InterceptRocket() {
+    }
+
+    public static <T extends Annotation> Object intercept(Long startDeliverTime, String shardingKeyFactory, RocketMessage rocketMessage, T annotation, Object proceed, Map<String, Object> consumerContainer, ThreadPoolExecutor threadPoolExecutor, ApplicationContext applicationContext) {
+        RocketSerializer mqSerializer = applicationContext.getBean(RocketSerializer.class);
+        byte[] body = mqSerializer.serialize(proceed);
+
+        ThreadPoolExecutorExecution.statsThread(threadPoolExecutor, new SendMessageFactoryExecution(startDeliverTime, shardingKeyFactory, consumerContainer, rocketMessage, annotation, body, applicationContext));
+        return proceed;
+    }
+}

+ 40 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/exception/RocketException.java

@@ -0,0 +1,40 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.exception;
+
+/**
+ * ClassName: RocketException
+ * Description:
+ * date: 2019/4/27 16:44
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+public class RocketException extends Exception {
+
+	public RocketException(String message) {
+		super(message);
+	}
+
+	public RocketException(Throwable cause) {
+		super(cause);
+	}
+
+	public RocketException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

+ 104 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/props/AliyunRocketProperties.java

@@ -0,0 +1,104 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.props;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+
+/**
+ * 阿里云 Rocket MQ 配置项
+ *
+ * @author ThierrySquirrel
+ * @author Uncarbon
+ */
+@ConfigurationProperties(prefix = "helio.rocketmq.aliyun", ignoreInvalidFields = true)
+@Data
+public class AliyunRocketProperties {
+
+	/**
+	 * 设置 TCP 协议接入点,从控制台获取
+	 */
+	private String nameSrvAddr;
+
+	/**
+	 * 您在阿里云账号管理控制台中创建的 AccessKey,用于身份认证
+	 */
+	private String accessKey;
+
+	/**
+	 * 您在阿里云账号管理控制台中创建的 SecretKey,用于身份认证
+	 */
+	private String secretKey;
+
+	/**
+	 * 用户渠道,默认为:ALIYUN,聚石塔用户为:CLOUD
+	 */
+	private String onsChannel = "ALIYUN";
+
+	/**
+	 * 设置消息发送的超时时间,单位(毫秒),默认:3000
+	 */
+	private Integer sendMsgTimeoutMillis = 3000;
+
+	/**
+	 * 设置事务消息第一次回查的最快时间,单位(秒)
+	 */
+	private Integer checkImmunityTimeInSeconds = 5;
+
+	/**
+	 * 设置 RocketMessage 实例的消费线程数,阿里云默认:20
+	 * 默认cpu数量*2+1
+	 */
+	private Integer consumeThreadNums = Runtime.getRuntime().availableProcessors() * 2 + 1;
+
+	/**
+	 * 设置消息消费失败的最大重试次数,默认:16
+	 */
+	private Integer maxReconsumeTimes = 16;
+
+	/**
+	 * 设置每条消息消费的最大超时时间,超过设置时间则被视为消费失败,等下次重新投递再次消费。 每个业务需要设置一个合理的值,单位(分钟)。 默认:15
+	 */
+	private Integer consumeTimeout = 15;
+
+	/**
+	 * 只适用于顺序消息,设置消息消费失败的重试间隔时间默认100毫秒
+	 */
+	private Integer suspendTimeMilli = 100;
+
+	/**
+	 * 异步发送消息执行Callback的目标线程池
+	 */
+	private Integer callbackThreadNums = Runtime.getRuntime().availableProcessors() * 2 + 1;
+
+	/**
+	 * 初始化消费者线程数,(尽量和消费者数量一致)默认cpu数量*2+1
+	 */
+	private Integer createConsumeThreadNums = Runtime.getRuntime().availableProcessors() * 2 + 1;
+
+	/**
+	 * 初始化生产者线程数,(尽量和生产者数量一致)默认cpu数量*2+1
+	 */
+	private Integer createProducerThreadNums = Runtime.getRuntime().availableProcessors() * 2 + 1;
+
+	/**
+	 * 生产者发送消息线程数 默认cpu数量*2+1
+	 */
+	private Integer sendMessageThreadNums = Runtime.getRuntime().availableProcessors() * 2 + 1;
+
+}

+ 67 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/thread/AbstractConsumerThread.java

@@ -0,0 +1,67 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.thread;
+
+import cc.uncarbon.framework.rocketmq.annotation.MessageListener;
+import cc.uncarbon.framework.rocketmq.annotation.RocketListener;
+import cc.uncarbon.framework.rocketmq.core.factory.execution.MethodFactoryExecution;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import lombok.Data;
+
+/**
+ * ClassName: AbstractConsumerThread
+ * Description:
+ * date: 2019/4/27 20:03
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Data
+public abstract class AbstractConsumerThread implements Runnable {
+	private AliyunRocketProperties rocketProperties;
+	private RocketListener rocketListener;
+	private MessageListener consumerListener;
+	private MethodFactoryExecution methodFactoryExecution;
+
+	protected AbstractConsumerThread(AliyunRocketProperties rocketProperties, RocketListener rocketListener, MessageListener consumerListener, MethodFactoryExecution methodFactoryExecution) {
+		this.rocketProperties = rocketProperties;
+		this.rocketListener = rocketListener;
+		this.consumerListener = consumerListener;
+		this.methodFactoryExecution = methodFactoryExecution;
+	}
+
+	/**
+	 * 消费者开始监听
+	 *
+	 * @param rocketProperties       rocketProperties
+	 * @param rocketListener         rocketListener
+	 * @param consumerListener       consumerListener
+	 * @param methodFactoryExecution methodFactoryExecution
+	 */
+	protected abstract void statsConsumer(AliyunRocketProperties rocketProperties,
+										  RocketListener rocketListener,
+										  MessageListener consumerListener,
+										  MethodFactoryExecution methodFactoryExecution);
+
+	@Override
+	public void run() {
+		statsConsumer(this.getRocketProperties(),
+				this.getRocketListener(),
+				this.getConsumerListener(),
+				this.getMethodFactoryExecution());
+	}
+}

+ 65 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/thread/AbstractProducerThread.java

@@ -0,0 +1,65 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.thread;
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import cc.uncarbon.framework.rocketmq.props.AliyunRocketProperties;
+import lombok.Data;
+import org.springframework.context.ApplicationContext;
+
+import java.util.Map;
+
+/**
+ * ClassName: AbstractProducerThread
+ * Description:
+ * date: 2019/5/3 14:02
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Data
+public abstract class AbstractProducerThread implements Runnable {
+	private Map<String, Object> producerConsumer;
+	private RocketMessage rocketMessage;
+	private Object bean;
+	private AliyunRocketProperties rocketProperties;
+	private ApplicationContext applicationContext;
+
+	protected AbstractProducerThread(Map<String, Object> producerConsumer, RocketMessage rocketMessage, Object bean, AliyunRocketProperties rocketProperties, ApplicationContext applicationContext) {
+		this.producerConsumer = producerConsumer;
+		this.rocketMessage = rocketMessage;
+		this.bean = bean;
+		this.rocketProperties = rocketProperties;
+		this.applicationContext = applicationContext;
+	}
+
+	/**
+	 * 开始向容器装填
+	 *
+	 * @param producerConsumer   producerConsumer
+	 * @param rocketMessage      rocketMessage
+	 * @param bean               bean
+	 * @param rocketProperties   rocketProperties
+	 * @param applicationContext applicationContext
+	 */
+	protected abstract void statsPutProducer(Map<String, Object> producerConsumer, RocketMessage rocketMessage, Object bean, AliyunRocketProperties rocketProperties, ApplicationContext applicationContext);
+
+	@Override
+	public void run() {
+		statsPutProducer(producerConsumer, rocketMessage, bean, rocketProperties, applicationContext);
+	}
+}

+ 74 - 0
helio-starter-rocketmq-aliyun/src/main/java/cc/uncarbon/framework/rocketmq/thread/AbstractSendMessageThread.java

@@ -0,0 +1,74 @@
+/**
+ * Copyright 2019 the original author or authors.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 cc.uncarbon.framework.rocketmq.thread;
+
+import cc.uncarbon.framework.rocketmq.annotation.RocketMessage;
+import lombok.Data;
+import org.springframework.context.ApplicationContext;
+
+import java.util.Map;
+
+/**
+ * ClassName: AbstractSendMessageThread
+ * Description:
+ * date: 2019/4/29 21:39
+ *
+ * @author ThierrySquirrel
+ * @since JDK 1.8
+ */
+@Data
+public abstract class AbstractSendMessageThread implements Runnable {
+    private Long startDeliverTime;
+    private String shardingKeyFactory;
+    private Map<String, Object> consumerContainer;
+    private RocketMessage rocketMessage;
+    private Object message;
+    private byte[] bytes;
+    private ApplicationContext applicationContext;
+
+    protected AbstractSendMessageThread(Long startDeliverTime, String shardingKeyFactory, Map<String, Object> consumerContainer, RocketMessage rocketMessage, Object message, byte[] bytes, ApplicationContext applicationContext) {
+        this.startDeliverTime = startDeliverTime;
+        this.shardingKeyFactory = shardingKeyFactory;
+        this.consumerContainer = consumerContainer;
+        this.rocketMessage = rocketMessage;
+        this.message = message;
+        this.bytes = bytes;
+        this.applicationContext = applicationContext;
+    }
+
+    /**
+     * 开始发送消息
+     *
+     * @param startDeliverTime   startDeliverTime
+     * @param shardingKeyFactory shardingKeyFactory
+     * @param consumerContainer  consumerContainer
+     * @param rocketMessage      rocketMessage
+     * @param message            message
+     * @param bytes              bytes
+     * @param applicationContext applicationContext
+     */
+    protected abstract void statsSendMessage(Long startDeliverTime, String shardingKeyFactory, Map<String, Object> consumerContainer, RocketMessage rocketMessage, Object message, byte[] bytes, ApplicationContext applicationContext);
+
+    @Override
+    public void run() {
+        statsSendMessage (startDeliverTime, shardingKeyFactory, consumerContainer,
+                rocketMessage,
+                message,
+                bytes,
+                applicationContext);
+    }
+}

+ 2 - 0
helio-starter-rocketmq-aliyun/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+  cc.uncarbon.framework.rocketmq.config.AliyunRocketAutoConfiguration

+ 1 - 1
helio-starter-satoken/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 3 - 2
helio-starter-satoken/src/main/java/cc/uncarbon/framework/satoken/interceptor/DefaultSaTokenParseInterceptor.java

@@ -11,13 +11,14 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 /**
- * 从请求头解析并赋值到上下文
+ * 从请求头解析用户信息,并赋值到上下文
+ *
  * @author Uncarbon
  */
 @Slf4j
 public class DefaultSaTokenParseInterceptor implements AsyncHandlerInterceptor {
     @Override
-    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
         if (handler instanceof ResourceHttpRequestHandler) {
             // 直接放行静态资源
             return true;

+ 1 - 1
helio-starter-seata/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
helio-starter-test/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
helio-starter-web/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>helio-starters</artifactId>
         <groupId>cc.uncarbon.framework</groupId>
-        <version>1.2.1</version>
+        <version>1.3.0</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 0 - 26
helio-starter-web/src/main/java/cc/uncarbon/framework/web/config/CorsAutoConfiguration.java

@@ -1,26 +0,0 @@
-package cc.uncarbon.framework.web.config;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-/**
- * Spring Boot 2.4+ 跨域设置需要变化
- * 参考https://blog.csdn.net/jxysgzs/article/details/110818712
- */
-@Configuration
-public class CorsAutoConfiguration implements WebMvcConfigurer {
-
-    @Override
-    public void addCorsMappings(CorsRegistry registry) {
-        registry.addMapping("/**")
-                // 设置允许跨域请求的域名
-                .allowedOriginPatterns("*")
-                // 是否允许证书(cookies)
-                .allowCredentials(true)
-                // 设置允许的方法
-                .allowedMethods("*")
-                // 跨域允许时间
-                .maxAge(3600);
-    }
-}

+ 55 - 0
helio-starter-web/src/main/java/cc/uncarbon/framework/web/interceptor/DefaultTenantParseInterceptor.java

@@ -0,0 +1,55 @@
+package cc.uncarbon.framework.web.interceptor;
+
+import cc.uncarbon.framework.core.context.TenantContext;
+import cc.uncarbon.framework.core.context.UserContext;
+import cc.uncarbon.framework.core.context.UserContextHolder;
+import cn.hutool.core.util.StrUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.servlet.AsyncHandlerInterceptor;
+import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 从请求头解析租户信息,并赋值到上下文
+ *
+ * @author Uncarbon
+ */
+@Slf4j
+public class DefaultTenantParseInterceptor implements AsyncHandlerInterceptor {
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
+        if (handler instanceof ResourceHttpRequestHandler) {
+            // 直接放行静态资源
+            return true;
+        }
+
+        /*
+        只有未登录的情况下,才从请求头的 X-TenantId 和 X-TenantName 字段读取租户信息
+        实际登录以后,用户上下文被更新,租户上下文随之固定
+
+        注:这里是读取明文,而且未考虑负数、自然对数、科学计数法等情况;出于安全考虑可以合并成一个字段,并密文形式传输,这里编码解密;注意异常处理
+         */
+        if (!UserContextHolder.isActuallyHold()) {
+            // 请求头里的租户ID,默认为-1
+            String headerTenantIdStr = StrUtil.blankToDefault(request.getHeader("X-TenantId"), "-1");
+            // 请求头里的租户名,可选
+            String headerTenantName = request.getHeader("X-TenantName");
+            if (StrUtil.isNumeric(headerTenantIdStr)) {
+                Long headerTenantId = Long.parseLong(headerTenantIdStr);
+                UserContextHolder.setUserContext(
+                        UserContext.builder()
+                                .relationalTenant(
+                                        TenantContext.builder()
+                                                .tenantId(headerTenantId)
+                                                .tenantName(headerTenantName)
+                                                .build()
+                                )
+                                .build()
+                );
+            }
+        }
+        return true;
+    }
+}

+ 1 - 2
helio-starter-web/src/main/resources/META-INF/spring.factories

@@ -4,5 +4,4 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
   cc.uncarbon.framework.web.config.AdviceExceptionAutoConfiguration,\
   cc.uncarbon.framework.web.config.JacksonExtendAutoConfiguration,\
   cc.uncarbon.framework.web.config.MessageConverterAutoConfiguration,\
-  cc.uncarbon.framework.web.config.XssAutoConfiguration,\
-  cc.uncarbon.framework.web.config.CorsAutoConfiguration
+  cc.uncarbon.framework.web.config.XssAutoConfiguration

+ 22 - 7
pom.xml

@@ -12,6 +12,7 @@
         <module>helio-starter-dubbo</module>
         <module>helio-starter-knife4j</module>
         <module>helio-starter-redis</module>
+        <module>helio-starter-rocketmq-aliyun</module>
         <module>helio-starter-satoken</module>
         <module>helio-starter-seata</module>
         <module>helio-starter-test</module>
@@ -21,21 +22,21 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.4.12</version>
+        <version>2.4.13</version>
         <relativePath/>
     </parent>
 
     <groupId>cc.uncarbon.framework</groupId>
     <artifactId>helio-starters</artifactId>
-    <version>1.2.1</version>
+    <version>1.3.0</version>
 
     <properties>
         <!-- core versions -->
-        <helio-starters.version>1.2.1</helio-starters.version>
+        <helio-starters.version>1.3.0</helio-starters.version>
         <!-- JDK8则改为'1.8'  JDK11则改为'11' -->
         <java.version>15</java.version>
         <!-- 若变更Spring Boot版本, 上面parent依赖版本也要变 -->
-        <spring-boot.version>2.4.12</spring-boot.version>
+        <spring-boot.version>2.4.13</spring-boot.version>
 
 
         <!-- Spring Cloud versions -->
@@ -51,13 +52,15 @@
 
 
         <!-- 3rd-party versions -->
-        <hutool.version>5.7.15</hutool.version>
+        <hutool.version>5.7.16</hutool.version>
+        <!-- 暂不升级,用 1.28.0 时存在 ThreadLocal 溢出问题,待观察 -->
         <sa-token.version>1.27.0</sa-token.version>
         <transmittable-thread-local.version>2.12.1</transmittable-thread-local.version>
         <mybatis-plus.version>3.4.3.4</mybatis-plus.version>
         <knife4j.version>3.0.3</knife4j.version>
         <redisson.version>3.16.3</redisson.version>
         <aspectj.version>1.9.6</aspectj.version>
+        <ons-client.version>1.8.8.1.Final</ons-client.version>
 
 
         <!-- DB Driver versions -->
@@ -68,7 +71,7 @@
         <oracle.version>11.2.0.3</oracle.version>
 
 
-        <!-- CI/CD -->
+        <!-- Maven properties -->
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <maven.version>3.6.3</maven.version>
@@ -77,7 +80,6 @@
         <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
         <buildTime>v.${project.version} build ${maven.build.timestamp.format}</buildTime>
         <main.user.dir>${basedir}/..</main.user.dir>
-        <jib-maven-plugin.version>3.0.0</jib-maven-plugin.version>
         <maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
     </properties>
 
@@ -140,6 +142,12 @@
                 <version>${helio-starters.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>cc.uncarbon.framework</groupId>
+                <artifactId>helio-starter-rocketmq-aliyun</artifactId>
+                <version>${helio-starters.version}</version>
+            </dependency>
+
             <dependency>
                 <groupId>cc.uncarbon.framework</groupId>
                 <artifactId>helio-starter-satoken</artifactId>
@@ -317,6 +325,13 @@
                 </exclusions>
             </dependency>
 
+            <!-- ROCKETMQ-ALIYUN dependencies -->
+            <dependency>
+                <groupId>com.aliyun.openservices</groupId>
+                <artifactId>ons-client</artifactId>
+                <version>${ons-client.version}</version>
+            </dependency>
+
 
             <!-- SA-TOKEN dependencies -->
             <dependency>