fanli/src/main/java/com/yeshi/fanli/util/rocketmq/RocketMQLocalTransactionChecker.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/RocketMQMessageListener.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/resource/rocket/consumer.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/resource/rocket/producer.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/resource/rocket/transactionProducer.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/resource/spring.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/RocketMQLocalTransactionChecker.java
New file @@ -0,0 +1,20 @@ package com.yeshi.fanli.util.rocketmq; import org.springframework.stereotype.Component; import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.transaction.LocalTransactionChecker; import com.aliyun.openservices.ons.api.transaction.TransactionStatus; @Component public class RocketMQLocalTransactionChecker implements LocalTransactionChecker { public RocketMQLocalTransactionChecker() { } @Override public TransactionStatus check(Message msg) { // TODO Auto-generated method stub return null; } } fanli/src/main/java/com/yeshi/fanli/util/rocketmq/RocketMQMessageListener.java
New file @@ -0,0 +1,21 @@ package com.yeshi.fanli.util.rocketmq; import org.springframework.stereotype.Component; 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; @Component public class RocketMQMessageListener implements MessageListener { public RocketMQMessageListener() { } @Override public Action consume(Message message, ConsumeContext context) { return null; } } fanli/src/main/resource/rocket/consumer.xml
New file @@ -0,0 +1,42 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="msgListener" class="com.yeshi.fanli.util.rocketmq.RocketMQMessageListener"></bean> <!--Listener 配置 --> <!-- Group ID 订阅同一个 Topic,可以创建多个 ConsumerBean --> <bean id="consumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean" init-method="start" destroy-method="shutdown"> <property name="properties"> <!--消费者配置信息 --> <props> <prop key="AccessKey">LTAI4FwmTxVCuzTaoZtDiV8z</prop> <prop key="SecretKey">ixWg90QbYFKP6ae5xpAo2P1qwIyll5</prop> <prop key="GROUP_ID">GID_DEMO</prop> <prop key="NAMESRV_ADDR">http://MQ_INST_1205444665315884_BbaMbxF4.mq-internet-access.mq-internet.aliyuncs.com:80 </prop> <!--将消费者线程数固定为 50 个 <prop key="ConsumeThreadNums">50</prop> --> </props> </property> <property name="subscriptionTable"> <map> <entry value-ref="msgListener"> <key> <bean class="com.aliyun.openservices.ons.api.bean.Subscription"> <property name="topic" value="TopicTestMQ" /> <property name="expression" value="*" /><!--expression 即 Tag,可以设置成具体的 Tag,如 taga||tagb||tagc,也可设置成 *。 * 仅代表订阅所有 Tag,不支持通配 --> </bean> </key> </entry> <!--更多的订阅添加 entry 节点即可,如下所示 --> <entry value-ref="msgListener"> <key> <bean class="com.aliyun.openservices.ons.api.bean.Subscription"> <property name="topic" value="TopicTestMQ-Other" /> <!--订阅另外一个 Topic --> <property name="expression" value="taga||tagb" /> <!-- 订阅多个 Tag --> </bean> </key> </entry> </map> </property> </bean> </beans> fanli/src/main/resource/rocket/producer.xml
New file @@ -0,0 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="producer" class="com.aliyun.openservices.ons.api.bean.ProducerBean" init-method="start" destroy-method="shutdown"> <!-- Spring 接入方式支持 Java SDK 支持的所有配置项 --> <property name="properties"> <!--生产者配置信息 --> <props> <prop key="AccessKey">LTAI4FwmTxVCuzTaoZtDiV8z</prop> <prop key="SecretKey">ixWg90QbYFKP6ae5xpAo2P1qwIyll5</prop> <prop key="NAMESRV_ADDR">http://MQ_INST_1205444665315884_BbaMbxF4.mq-internet-access.mq-internet.aliyuncs.com:80 </prop> <!--将消费者线程数固定为 50 个 <prop key="ConsumeThreadNums">50</prop> --> </props> </property> </bean> </beans> fanli/src/main/resource/rocket/transactionProducer.xml
New file @@ -0,0 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- 事务消息生产 --> <bean id="localTransactionChecker" class="com.yeshi.fanli.util.rocketmq.RocketMQLocalTransactionChecker"></bean> <bean id="transactionProducer" class="com.aliyun.openservices.ons.api.bean.TransactionProducerBean" init-method="start" destroy-method="shutdown"> <property name="properties"> <!--事务消息生产者配置信息 --> <props> <prop key="AccessKey">LTAI4FwmTxVCuzTaoZtDiV8z</prop> <prop key="SecretKey">ixWg90QbYFKP6ae5xpAo2P1qwIyll5</prop> <prop key="GROUP_ID">GID_DEMO</prop> <prop key="NAMESRV_ADDR">http://MQ_INST_1205444665315884_BbaMbxF4.mq-internet-access.mq-internet.aliyuncs.com:80 </prop> </props> </property> <property name="localTransactionChecker" ref="localTransactionChecker"></property> </bean> </beans> fanli/src/main/resource/spring.xml
@@ -48,6 +48,10 @@ </array> </property> </bean> <import resource="classpath:/rocket/consumer.xml"/> <import resource="classpath:/rocket/producer.xml"/> <import resource="classpath:/rocket/transactionProducer.xml"/> <!--异步定义推荐方式 <task:executor id="executor" pool-size="15" /> <task:scheduler id="scheduler" pool-size="30" /> <task:annotation-driven executor="executor" pom.xml
@@ -532,6 +532,12 @@ <version>0.4.8</version> </dependency> <dependency> <groupId>com.aliyun.openservices</groupId> <artifactId>ons-client</artifactId> <version>1.8.0.Final</version> </dependency> </dependencies>