From 5e7b0ed4a154ad067cbcf4aa1a1c7cce32f9864c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 26 四月 2024 18:02:17 +0800 Subject: [PATCH] 唯品会链接解析升级 --- fanli/src/main/java/com/yeshi/fanli/service/manger/msg/RocketMQManager.java | 208 ++++++++++++++++++++++++++-------------------------- 1 files changed, 104 insertions(+), 104 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/manger/msg/RocketMQManager.java b/fanli/src/main/java/com/yeshi/fanli/service/manger/msg/RocketMQManager.java index 6330105..e1ec826 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/manger/msg/RocketMQManager.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/manger/msg/RocketMQManager.java @@ -1,104 +1,104 @@ -package com.yeshi.fanli.service.manger.msg; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Component; - -import com.aliyun.openservices.ons.api.Message; -import com.aliyun.openservices.ons.api.Producer; -import com.aliyun.openservices.ons.api.SendResult; -import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter; -import com.aliyun.openservices.ons.api.transaction.TransactionProducer; -import com.aliyun.openservices.ons.api.transaction.TransactionStatus; - -/** - * RocketMQ绠$悊鍣� - * @author Administrator - * - */ -@Component -public class RocketMQManager { - @Resource(name = "producer") - private Producer producer; - @Resource - private TransactionProducer orderTransactionProducer; - - /** - * 鍙戦�佹櫘閫氭秷鎭� - * @Title: sendNormalMsg - * @Description: - * @param message - * void 杩斿洖绫诲瀷 - * @throws - */ - public SendResult sendNormalMsg(Message message, String key) { - return sendNormalMsg(message, null, key); - } - - /** - * 鍙戦�佹櫘閫氬畾鏃舵秷鎭� - * @Title: sendNormalMsg - * @Description: - * @param message - * @param delayTimeMS 寤舵椂ms - * void 杩斿洖绫诲瀷 - * @throws - */ - public SendResult sendNormalMsg(Message message, Long delayTimeMS, String key) { - if (message == null) - return null; - if (key != null) - message.setKey(key); - if (delayTimeMS != null) - message.setStartDeliverTime(System.currentTimeMillis() + delayTimeMS);// 10s鍚庡彂閫佹椿璺冩秷鎭� - return producer.send(message); - } - - /** - * 鍙戦�佷簨鍔℃秷鎭� - * @Title: sendTransactionalMsg - * @Description: - * @param message - * @param delayTimeMS 寤舵椂ms - * @param key - * @param mqEvent - * @throws Exception - * void 杩斿洖绫诲瀷 - * @throws - */ - public void sendTransactionalMsg(Message message, Long delayTimeMS, String key, ITransactionalMQEvent mqEvent) - throws Exception { - if (key != null) - message.setKey(key); - if (delayTimeMS != null) - message.setStartDeliverTime(System.currentTimeMillis() + delayTimeMS); - - orderTransactionProducer.send(message, new LocalTransactionExecuter() { - @Override - public TransactionStatus execute(Message arg0, Object arg1) { - if (mqEvent != null) - mqEvent.excute(); - return TransactionStatus.CommitTransaction; - } - }, null); - } - - /** - * 鍙戦�佷簨鍔℃秷鎭� - * @Title: sendTransactionalMsg - * @Description: - * @param message - * @param key - * @param mqEvent - * @throws Exception - * void 杩斿洖绫诲瀷 - * @throws - */ - public void sendTransactionalMsg(Message message, String key, ITransactionalMQEvent mqEvent) throws Exception { - sendTransactionalMsg(message, null, key, mqEvent); - } - - interface ITransactionalMQEvent { - public void excute(); - } -} +package com.yeshi.fanli.service.manger.msg; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Component; + +import com.aliyun.openservices.ons.api.Message; +import com.aliyun.openservices.ons.api.Producer; +import com.aliyun.openservices.ons.api.SendResult; +import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter; +import com.aliyun.openservices.ons.api.transaction.TransactionProducer; +import com.aliyun.openservices.ons.api.transaction.TransactionStatus; + +/** + * RocketMQ绠$悊鍣� + * @author Administrator + * + */ +@Component +public class RocketMQManager { + @Resource(name = "producer") + private Producer producer; + @Resource + private TransactionProducer orderTransactionProducer; + + /** + * 鍙戦�佹櫘閫氭秷鎭� + * @Title: sendNormalMsg + * @Description: + * @param message + * void 杩斿洖绫诲瀷 + * @throws + */ + public SendResult sendNormalMsg(Message message, String key) { + return sendNormalMsg(message, null, key); + } + + /** + * 鍙戦�佹櫘閫氬畾鏃舵秷鎭� + * @Title: sendNormalMsg + * @Description: + * @param message + * @param delayTimeMS 寤舵椂ms + * void 杩斿洖绫诲瀷 + * @throws + */ + public SendResult sendNormalMsg(Message message, Long delayTimeMS, String key) { + if (message == null) + return null; + if (key != null) + message.setKey(key); + if (delayTimeMS != null) + message.setStartDeliverTime(System.currentTimeMillis() + delayTimeMS);// 10s鍚庡彂閫佹椿璺冩秷鎭� + return producer.send(message); + } + + /** + * 鍙戦�佷簨鍔℃秷鎭� + * @Title: sendTransactionalMsg + * @Description: + * @param message + * @param delayTimeMS 寤舵椂ms + * @param key + * @param mqEvent + * @throws Exception + * void 杩斿洖绫诲瀷 + * @throws + */ + public void sendTransactionalMsg(Message message, Long delayTimeMS, String key, ITransactionalMQEvent mqEvent) + throws Exception { + if (key != null) + message.setKey(key); + if (delayTimeMS != null) + message.setStartDeliverTime(System.currentTimeMillis() + delayTimeMS); + + orderTransactionProducer.send(message, new LocalTransactionExecuter() { + @Override + public TransactionStatus execute(Message arg0, Object arg1) { + if (mqEvent != null) + return mqEvent.excute( arg0, arg1); + return TransactionStatus.CommitTransaction; + } + }, null); + } + + /** + * 鍙戦�佷簨鍔℃秷鎭� + * @Title: sendTransactionalMsg + * @Description: + * @param message + * @param key + * @param mqEvent + * @throws Exception + * void 杩斿洖绫诲瀷 + * @throws + */ + public void sendTransactionalMsg(Message message, String key, ITransactionalMQEvent mqEvent) throws Exception { + sendTransactionalMsg(message, null, key, mqEvent); + } + + public interface ITransactionalMQEvent { + public TransactionStatus excute(Message arg0, Object arg1); + } +} -- Gitblit v1.8.0