Commit 0ba6b3bd authored by xiaoyu's avatar xiaoyu
Browse files

MQ整体优化

parent 010d8799
......@@ -151,6 +151,15 @@ public class CS {
/** 用于activemq 发布订阅模式交换机**/
String FANOUT_MODIFY_SYS_CONFIG = "fanout.modify.sys.config";
/** MQ消息类型 **/
String MQ_TYPE_MODIFY_MCH_APP = "modify.mch.app";
String MQ_TYPE_MODIFY_ISV_INFO = "modify.isv.info";
String MQ_TYPE_MODIFY_MCH_INFO = "modify.mch.info";
String MQ_TYPE_MODIFY_SYS_CONFIG = "modify.sys.config";
String MQ_TYPE_CHANNEL_ORDER_QUERY = "channel.order.query";
String MQ_TYPE_PAY_ORDER_MCH_NOTIFY = "pay.order.mch.notify";
String MQ_TYPE_MCH_LOGIN_USER_REMOVE = "mch.login.user.remove";
}
/** RabbitMQ交换机类型 **/
......
......@@ -13,19 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mgr.mq.service;
import java.util.Collection;
package com.jeequan.jeepay.core.mq;
/**
* mq消息中转抽象类
*
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
public abstract class MqMchUserRemoveService {
public abstract class MqCommonService {
/**
* 消息发送
* @param msg
* @param sendType
*/
public abstract void send(String msg, String sendType);
public abstract void send(Collection<Long> userIdList);
/**
* 延迟消息发送
* @param msg
* @param delay
* @param sendType
*/
public abstract void send(String msg, long delay, String sendType);
}
......@@ -19,10 +19,11 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.SysConfig;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -49,7 +50,7 @@ import java.util.Map;
public class SysConfigController extends CommonCtrl {
@Autowired private SysConfigService sysConfigService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MqCommonService mqCommonService;
/**
......@@ -84,7 +85,7 @@ public class SysConfigController extends CommonCtrl {
int update = sysConfigService.updateByConfigKey(updateMap);
if(update <= 0) return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "更新失败");
mqSendServiceImpl.sendModifySysConfig(groupKey);
mqCommonService.send(groupKey, CS.MQ.MQ_TYPE_MODIFY_SYS_CONFIG);
return ApiRes.ok();
}
......
......@@ -20,10 +20,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.IsvInfo;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.IsvInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,7 +46,7 @@ import org.springframework.web.bind.annotation.RestController;
public class IsvInfoController extends CommonCtrl {
@Autowired private IsvInfoService isvInfoService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MqCommonService mqCommonService;
/**
* @author: pangxiaoyu
......@@ -95,7 +96,7 @@ public class IsvInfoController extends CommonCtrl {
@RequestMapping(value="/{isvNo}", method = RequestMethod.DELETE)
public ApiRes delete(@PathVariable("isvNo") String isvNo) {
isvInfoService.removeByIsvNo(isvNo);
mqSendServiceImpl.sendModifyIsvInfo(isvNo); // 推送mq到目前节点进行更新数据
mqCommonService.send(isvNo, CS.MQ.MQ_TYPE_MODIFY_ISV_INFO); // 推送mq到目前节点进行更新数据
return ApiRes.ok();
}
......@@ -111,7 +112,7 @@ public class IsvInfoController extends CommonCtrl {
IsvInfo isvInfo = getObject(IsvInfo.class);
isvInfo.setIsvNo(isvNo);
boolean result = isvInfoService.updateById(isvInfo);
mqSendServiceImpl.sendModifyIsvInfo(isvNo); // 推送mq到目前节点进行更新数据
mqCommonService.send(isvNo, CS.MQ.MQ_TYPE_MODIFY_ISV_INFO); // 推送mq到目前节点进行更新数据
if (!result) return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
return ApiRes.ok();
}
......
......@@ -21,8 +21,8 @@ import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
import com.jeequan.jeepay.core.entity.PayInterfaceDefine;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -43,7 +43,7 @@ import java.util.List;
public class IsvPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MqCommonService mqCommonService;
/**
* @Author: ZhuXiao
......@@ -114,7 +114,7 @@ public class IsvPayInterfaceConfigController extends CommonCtrl {
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "配置失败");
}
mqSendServiceImpl.sendModifyIsvInfo(infoId); // 推送mq到目前节点进行更新数据
mqCommonService.send(infoId, CS.MQ.MQ_TYPE_MODIFY_ISV_INFO); // 推送mq到目前节点进行更新数据
return ApiRes.ok();
}
......
......@@ -16,14 +16,17 @@
package com.jeequan.jeepay.mgr.ctrl.merchant;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.core.utils.JsonKit;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.MchAppService;
import com.jeequan.jeepay.service.impl.MchInfoService;
import org.apache.commons.lang3.StringUtils;
......@@ -44,7 +47,7 @@ public class MchAppController extends CommonCtrl {
@Autowired private MchInfoService mchInfoService;
@Autowired private MchAppService mchAppService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MqCommonService mqCommonService;
/**
* @Author: ZhuXiao
......@@ -122,7 +125,9 @@ public class MchAppController extends CommonCtrl {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
// 推送修改应用消息
mqSendServiceImpl.sendModifyMchApp(mchApp.getMchNo(), mchApp.getAppId());
JSONObject jsonObject = JsonKit.newJson("mchNo", mchApp.getMchNo());
jsonObject.put("appId", appId);
mqCommonService.send(jsonObject.toJSONString(), CS.MQ.MQ_TYPE_MODIFY_MCH_APP);
return ApiRes.ok();
}
......@@ -140,7 +145,9 @@ public class MchAppController extends CommonCtrl {
mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyMchApp(mchApp.getMchNo(), appId);
JSONObject jsonObject = JsonKit.newJson("mchNo", mchApp.getMchNo());
jsonObject.put("appId", appId);
mqCommonService.send(jsonObject.toJSONString(), CS.MQ.MQ_TYPE_MODIFY_MCH_APP);
return ApiRes.ok();
}
......
......@@ -17,6 +17,7 @@ package com.jeequan.jeepay.mgr.ctrl.merchant;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.aop.MethodLog;
......@@ -25,8 +26,8 @@ import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchInfo;
import com.jeequan.jeepay.core.entity.SysUser;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.MchInfoService;
import com.jeequan.jeepay.service.impl.SysUserAuthService;
import com.jeequan.jeepay.service.impl.SysUserService;
......@@ -56,7 +57,7 @@ public class MchInfoController extends CommonCtrl {
@Autowired private MchInfoService mchInfoService;
@Autowired private SysUserService sysUserService;
@Autowired private SysUserAuthService sysUserAuthService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MqCommonService mqCommonService;
/**
* @author: pangxiaoyu
......@@ -113,9 +114,9 @@ public class MchInfoController extends CommonCtrl {
public ApiRes delete(@PathVariable("mchNo") String mchNo) {
List<Long> userIdList = mchInfoService.removeByMchNo(mchNo);
// 推送mq删除redis用户缓存
mqSendServiceImpl.sendUserRemove(userIdList);
mqCommonService.send(JSONArray.toJSONString(userIdList), CS.MQ.MQ_TYPE_MCH_LOGIN_USER_REMOVE);
// 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyMchInfo(mchNo);
mqCommonService.send(mchNo, CS.MQ.MQ_TYPE_MODIFY_MCH_INFO);
return ApiRes.ok();
}
......@@ -161,7 +162,7 @@ public class MchInfoController extends CommonCtrl {
// 推送mq删除redis用户认证信息
if (!removeCacheUserIdList.isEmpty()) {
mqSendServiceImpl.sendUserRemove(removeCacheUserIdList);
mqCommonService.send(JSONArray.toJSONString(removeCacheUserIdList), CS.MQ.MQ_TYPE_MCH_LOGIN_USER_REMOVE);
}
//更新商户信息
......@@ -170,7 +171,7 @@ public class MchInfoController extends CommonCtrl {
}
// 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyMchInfo(mchNo);
mqCommonService.send(mchNo, CS.MQ.MQ_TYPE_MODIFY_MCH_INFO);
return ApiRes.ok();
}
......
......@@ -15,6 +15,7 @@
*/
package com.jeequan.jeepay.mgr.ctrl.merchant;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS;
......@@ -22,8 +23,9 @@ import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
import com.jeequan.jeepay.core.entity.PayInterfaceDefine;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.core.utils.JsonKit;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.MchAppService;
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,8 +47,8 @@ import java.util.List;
public class MchPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MchAppService mchAppService;
@Autowired private MqCommonService mqCommonService;
/**
* @Author: ZhuXiao
......@@ -123,8 +125,9 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "配置失败");
}
mqSendServiceImpl.sendModifyMchApp(mchApp.getMchNo(), infoId); // 推送mq到目前节点进行更新数据
JSONObject jsonObject = JsonKit.newJson("mchNo", mchApp.getMchNo());
jsonObject.put("appId", infoId);
mqCommonService.send(jsonObject.toJSONString(), CS.MQ.MQ_TYPE_MODIFY_MCH_APP); // 推送mq到目前节点进行更新数据
return ApiRes.ok();
}
......
......@@ -19,11 +19,12 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchNotifyRecord;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.MchNotifyRecordService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,7 +46,7 @@ import org.springframework.web.bind.annotation.RestController;
public class MchNotifyController extends CommonCtrl {
@Autowired private MchNotifyRecordService mchNotifyService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MqCommonService mqCommonService;
/**
* @author: pangxiaoyu
......@@ -106,7 +107,7 @@ public class MchNotifyController extends CommonCtrl {
mchNotifyService.getBaseMapper().updateIngAndAddNotifyCountLimit(notifyId);
//调起MQ重发
mqSendServiceImpl.sendPayOrderNotify(notifyId+"");
mqCommonService.send(notifyId+"", CS.MQ.MQ_TYPE_PAY_ORDER_MCH_NOTIFY);
return ApiRes.ok(mchNotify);
}
......
......@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mgr.mq.topic;
package com.jeequan.jeepay.mgr.mq;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifySysConfigService;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.service.impl.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -29,31 +30,135 @@ import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
/*
* 更改系统配置参数
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/6/8 17:13
*/
import javax.jms.Queue;
/**
*
* @author pangxiaoyu
* @site https://www.jeepay.vip
* @date 2021-06-07 07:15
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqTopic4ModifySysConfig extends MqModifySysConfigService {
public class ActiveMqSend extends MqCommonService {
@Autowired private JmsTemplate jmsTemplate;
@Autowired private SysConfigService sysConfigService;
@Bean("activeModifySysConfig")
@Bean("activeMqSendModifyMchUserRemove")
public Queue mqQueue4ModifyMchUserRemove(){
return new ActiveMQQueue(CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE);
}
@Lazy
@Autowired
@Qualifier("activeMqSendModifyMchUserRemove")
private Queue mqQueue4ModifyMchUserRemove;
@Bean("activeMqSendPayOrderMchNotify")
public Queue mqQueue4PayOrderMchNotify(){
return new ActiveMQQueue(CS.MQ.QUEUE_PAYORDER_MCH_NOTIFY);
}
@Lazy
@Autowired
@Qualifier("activeMqSendPayOrderMchNotify")
private Queue mqQueue4PayOrderMchNotify;
@Bean("activeMqSendModifyIsvInfo")
public ActiveMQTopic mqTopic4ModifyIsvInfo(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_ISV_INFO);
}
@Lazy
@Autowired
@Qualifier("activeMqSendModifyIsvInfo")
private ActiveMQTopic mqTopic4ModifyIsvInfo;
@Bean("activeMqSendModifyMchApp")
public ActiveMQTopic mqTopic4ModifyMchApp(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_MCH_APP);
}
@Lazy
@Autowired
@Qualifier("activeMqSendModifyMchApp")
private ActiveMQTopic mqTopic4ModifyMchApp;
@Bean("activeMqSendModifyMchInfo")
public ActiveMQTopic mqTopic4ModifyMchInfo(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_MCH_INFO);
}
@Lazy
@Autowired
@Qualifier("activeMqSendModifyMchInfo")
private ActiveMQTopic mqTopic4ModifyMchInfo;
@Bean("activeMqSendModifySysConfig")
public ActiveMQTopic mqTopic4ModifySysConfig(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_SYS_CONFIG);
}
@Lazy
@Autowired
@Qualifier("activeModifySysConfig")
@Qualifier("activeMqSendModifySysConfig")
private ActiveMQTopic mqTopic4ModifySysConfig;
@Override
public void send(String msg, String sendType) {
if (sendType.equals(CS.MQ.MQ_TYPE_PAY_ORDER_MCH_NOTIFY)) { // 商户订单回调
queuePayOrderMchNotify(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_ISV_INFO)) { // 服务商信息修改
topicModifyIsvInfo(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_MCH_APP)) { // 商户应用修改
topicModifyMchApp(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_MCH_INFO)) { // 商户信息修改
topicModifyMchInfo(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_SYS_CONFIG)) { // 系统配置修改
topicModifySysConfig(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MCH_LOGIN_USER_REMOVE)) { // 商户登录用户清除信息
queueMchLoginUserRemove(msg);
}
}
@Override
public void send(String msg, long delay, String sendType) {
}
/** 发送商户订单回调消息 **/
public void queuePayOrderMchNotify(String msg) {
this.jmsTemplate.convertAndSend(mqQueue4PayOrderMchNotify, msg);
}
/** 发送服务商信息修改消息 **/
public void topicModifyIsvInfo(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifyIsvInfo, msg);
}
/** 发送商户应用修改消息 **/
public void topicModifyMchApp(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifyMchApp, msg);
}
/** 发送商户信息修改消息 **/
public void topicModifyMchInfo(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifyMchInfo, msg);
}
/** 发送系统配置修改消息 **/
public void topicModifySysConfig(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifySysConfig, msg);
}
/** 发送商户登录用户清除信息消息 **/
public void queueMchLoginUserRemove(String msg) { this.jmsTemplate.convertAndSend(mqQueue4ModifyMchUserRemove, msg); }
/** 接收 更新系统配置项的消息 **/
@JmsListener(destination = CS.MQ.TOPIC_MODIFY_SYS_CONFIG, containerFactory = "jmsListenerContainer")
public void receive(String msg) {
......@@ -63,11 +168,4 @@ public class MqTopic4ModifySysConfig extends MqModifySysConfigService {
log.info("系统配置静态属性已重置");
}
/** 推送消息到各个节点 **/
@Override
public void send(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifySysConfig, msg);
}
}
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mgr.mq.topic;
package com.jeequan.jeepay.mgr.mq;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifySysConfigService;
import com.jeequan.jeepay.core.mq.MqCommonService;
import com.jeequan.jeepay.service.impl.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
......@@ -29,20 +29,72 @@ import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
/**
* RabbitMq
* 系统信息修改推送
* @author xiaoyu
*
* @author pangxiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
* @date 2021-06-07 07:15
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqDirect4ModifySysConfig extends MqModifySysConfigService {
public class RabbitMqSend extends MqCommonService {
@Autowired private AmqpTemplate rabbitTemplate;
@Autowired private SysConfigService sysConfigService;
@Override
public void send(String msg, String sendType) {
if (sendType.equals(CS.MQ.MQ_TYPE_PAY_ORDER_MCH_NOTIFY)) { // 商户订单回调
payOrderMchNotify(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_ISV_INFO)) { // 服务商信息修改
directModifyIsvInfo(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_MCH_APP)) { // 商户应用修改
directModifyMchApp(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_MCH_INFO)) { // 商户信息修改
directModifyMchInfo(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_SYS_CONFIG)) { // 系统配置修改
fanoutModifySysConfig(msg);
}else if (sendType.equals(CS.MQ.MQ_TYPE_MCH_LOGIN_USER_REMOVE)) { // 商户登录用户清除信息
directMchLoginUserRemove(msg);
}
}
@Override
public void send(String msg, long delay, String sendType) {
}
/** 发送商户订单回调消息 **/
public void payOrderMchNotify(String msg) {
rabbitTemplate.convertAndSend(CS.MQ.QUEUE_PAYORDER_MCH_NOTIFY, msg);
}
/** 发送服务商信息修改消息 **/
public void directModifyIsvInfo(String msg) {
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_ISV_INFO, msg);
}
/** 发送商户应用修改消息 **/
public void directModifyMchApp(String msg) {
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_APP, msg);
}
/** 发送商户信息修改消息 **/
public void directModifyMchInfo(String msg) {
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_INFO, msg);
}
/** 发送系统配置修改消息 **/
public void fanoutModifySysConfig(String msg) {
this.rabbitTemplate.convertAndSend(CS.FANOUT_EXCHANGE_SYS_CONFIG, CS.MQ.FANOUT_MODIFY_SYS_CONFIG, msg);
}
/** 发送商户登录用户清除信息消息 **/
public void directMchLoginUserRemove(String msg) {
this.rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE, msg);
}
/** 接收 更新系统配置项的消息 **/
@RabbitListener(bindings = {@QueueBinding(value = @Queue(),exchange = @Exchange(name = CS.FANOUT_EXCHANGE_SYS_CONFIG,type = "fanout"))})
public void receive(String msg) {
......@@ -51,10 +103,4 @@ public class RabbitMqDirect4ModifySysConfig extends MqModifySysConfigService {
log.info("系统配置静态属性已重置");
}
/** 推送消息到各个节点 **/
@Override
public void send(String msg) {
this.rabbitTemplate.convertAndSend(CS.FANOUT_EXCHANGE_SYS_CONFIG, CS.MQ.FANOUT_MODIFY_SYS_CONFIG, msg);
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mgr.mq.topic;
package com.jeequan.jeepay.mgr.mq.config;
import com.jeequan.jeepay.core.constants.CS;
import org.springframework.context.annotation.Bean;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mgr.mq.topic;
package com.jeequan.jeepay.mgr.mq.config;
import com.jeequan.jeepay.core.constants.CS;
import org.springframework.amqp.core.*;
......@@ -30,9 +30,9 @@ import org.springframework.context.annotation.Profile;
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Profile(CS.MQTYPE.RABBIT_MQ)
@Configuration
@EnableRabbit
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqConfig {
@Bean("modifyIsvInfo")
......
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <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 com.jeequan.jeepay.mgr.mq.queue;
import com.alibaba.fastjson.JSONArray;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqMchUserRemoveService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
import javax.jms.Queue;
import java.util.Collection;
/**
* 商户用户信息清除
*
* @author pangxiaoyu
* @site https://www.jeepay.vip
* @date 2021-06-07 07:15
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqQueue4ModifyMchUserRemove extends MqMchUserRemoveService {
@Autowired private JmsTemplate jmsTemplate;
@Bean("activeModifyMchUserRemove")
public Queue mqQueue4ModifyMchUserRemove(){
return new ActiveMQQueue(CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE);
}
@Lazy
@Autowired
@Qualifier("activeModifyMchUserRemove")
private Queue mqQueue4ModifyMchUserRemove;
@Override
public void send(Collection<Long> userIdList) {
if(userIdList == null || userIdList.isEmpty()){
return ;
}
this.jmsTemplate.convertAndSend(mqQueue4ModifyMchUserRemove, JSONArray.toJSONString(userIdList));
}
}
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <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 com.jeequan.jeepay.mgr.mq.queue;
import com.alibaba.fastjson.JSONArray;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqMchUserRemoveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import java.util.Collection;
/**
* Rabbitmq
* 商户用户信息清除
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMq4ModifyMchUserRemove extends MqMchUserRemoveService {
@Autowired private AmqpTemplate rabbitTemplate;
@Override
public void send(Collection<Long> userIdList) {
if(userIdList == null || userIdList.isEmpty()){
return ;
}
rabbitTemplate.convertAndSend(CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE, JSONArray.toJSONString(userIdList));
}
}
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <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 com.jeequan.jeepay.mgr.mq.queue;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqPayOrderNotifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
/**
* Rabbitmq
* 商户订单回调MQ通知
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMq4PayOrderMchNotify extends MqPayOrderNotifyService {
@Autowired
private AmqpTemplate rabbitTemplate;
@Override
public void send(String msg) {
rabbitTemplate.convertAndSend(CS.MQ.QUEUE_PAYORDER_MCH_NOTIFY, msg);
}
}
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <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 com.jeequan.jeepay.mgr.mq.service;
/**
* mq消息中转抽象类
*
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
public abstract class MqModifyIsvInfoService {
public abstract void send(String msg);
}
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <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 com.jeequan.jeepay.mgr.mq.service;
/**
* mq消息中转抽象类
*
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
public abstract class MqModifyMchAppService {
public abstract void send(String mchNo, String appId);
}
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <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 com.jeequan.jeepay.mgr.mq.service;
/**
* mq消息中转抽象类
*
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
public abstract class MqModifyMchInfoService {
public abstract void send(String mchNo);
}
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <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 com.jeequan.jeepay.mgr.mq.service;
/**
* mq消息中转抽象类
*
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
public abstract class MqModifySysConfigService {
public abstract void send(String msg);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment