Commit 010d8799 authored by xiaoyu's avatar xiaoyu
Browse files

mq优化

parent a4ed4566
......@@ -148,12 +148,15 @@ public class CS {
/** 清除商户登录用户信息 **/
String QUEUE_MODIFY_MCH_USER_REMOVE = "queue.modify.mch.user.remove";
/** 用于activemq 发布订阅模式交换机**/
String FANOUT_MODIFY_SYS_CONFIG = "fanout.modify.sys.config";
}
/** RabbitMQ交换机类型 **/
public static final String TOPIC_EXCHANGE = "topicExchange";
public static final String DIRECT_EXCHANGE = "directExchange";
public static final String DELAYED_EXCHANGE = "delayedExchange"; // 延迟交换机
public static final String FANOUT_EXCHANGE_SYS_CONFIG = "fanoutExchangeSysConfig";
/** 切换MQ的类型 **/
public static class MQTYPE{
public static final String ACTIVE_MQ = "activeMQ";
......
......@@ -22,7 +22,7 @@ import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.entity.SysConfig;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqServiceImpl;
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 +49,7 @@ import java.util.Map;
public class SysConfigController extends CommonCtrl {
@Autowired private SysConfigService sysConfigService;
@Autowired private MqServiceImpl mqService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
/**
......@@ -84,7 +84,7 @@ public class SysConfigController extends CommonCtrl {
int update = sysConfigService.updateByConfigKey(updateMap);
if(update <= 0) return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "更新失败");
mqService.sendModifySysConfig(groupKey);
mqSendServiceImpl.sendModifySysConfig(groupKey);
return ApiRes.ok();
}
......
......@@ -23,7 +23,7 @@ import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.entity.IsvInfo;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqServiceImpl;
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 +45,7 @@ import org.springframework.web.bind.annotation.RestController;
public class IsvInfoController extends CommonCtrl {
@Autowired private IsvInfoService isvInfoService;
@Autowired private MqServiceImpl mqServiceImpl;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
/**
* @author: pangxiaoyu
......@@ -95,7 +95,7 @@ public class IsvInfoController extends CommonCtrl {
@RequestMapping(value="/{isvNo}", method = RequestMethod.DELETE)
public ApiRes delete(@PathVariable("isvNo") String isvNo) {
isvInfoService.removeByIsvNo(isvNo);
mqServiceImpl.sendModifyIsvInfo(isvNo); // 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyIsvInfo(isvNo); // 推送mq到目前节点进行更新数据
return ApiRes.ok();
}
......@@ -111,7 +111,7 @@ public class IsvInfoController extends CommonCtrl {
IsvInfo isvInfo = getObject(IsvInfo.class);
isvInfo.setIsvNo(isvNo);
boolean result = isvInfoService.updateById(isvInfo);
mqServiceImpl.sendModifyIsvInfo(isvNo); // 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyIsvInfo(isvNo); // 推送mq到目前节点进行更新数据
if (!result) return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
return ApiRes.ok();
}
......
......@@ -22,7 +22,7 @@ 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.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqServiceImpl;
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 MqServiceImpl mqServiceImpl;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
/**
* @Author: ZhuXiao
......@@ -114,7 +114,7 @@ public class IsvPayInterfaceConfigController extends CommonCtrl {
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "配置失败");
}
mqServiceImpl.sendModifyIsvInfo(infoId); // 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyIsvInfo(infoId); // 推送mq到目前节点进行更新数据
return ApiRes.ok();
}
......
......@@ -23,7 +23,7 @@ import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqServiceImpl;
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 +44,7 @@ public class MchAppController extends CommonCtrl {
@Autowired private MchInfoService mchInfoService;
@Autowired private MchAppService mchAppService;
@Autowired private MqServiceImpl mqServiceImpl;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
/**
* @Author: ZhuXiao
......@@ -122,7 +122,7 @@ public class MchAppController extends CommonCtrl {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
// 推送修改应用消息
mqServiceImpl.sendModifyMchApp(mchApp.getMchNo(), mchApp.getAppId());
mqSendServiceImpl.sendModifyMchApp(mchApp.getMchNo(), mchApp.getAppId());
return ApiRes.ok();
}
......@@ -140,7 +140,7 @@ public class MchAppController extends CommonCtrl {
mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据
mqServiceImpl.sendModifyMchApp(mchApp.getMchNo(), appId);
mqSendServiceImpl.sendModifyMchApp(mchApp.getMchNo(), appId);
return ApiRes.ok();
}
......
......@@ -26,7 +26,7 @@ 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.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqServiceImpl;
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 +56,7 @@ public class MchInfoController extends CommonCtrl {
@Autowired private MchInfoService mchInfoService;
@Autowired private SysUserService sysUserService;
@Autowired private SysUserAuthService sysUserAuthService;
@Autowired private MqServiceImpl mqServiceImpl;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
/**
* @author: pangxiaoyu
......@@ -113,9 +113,9 @@ public class MchInfoController extends CommonCtrl {
public ApiRes delete(@PathVariable("mchNo") String mchNo) {
List<Long> userIdList = mchInfoService.removeByMchNo(mchNo);
// 推送mq删除redis用户缓存
mqServiceImpl.sendUserRemove(userIdList);
mqSendServiceImpl.sendUserRemove(userIdList);
// 推送mq到目前节点进行更新数据
mqServiceImpl.sendModifyMchInfo(mchNo);
mqSendServiceImpl.sendModifyMchInfo(mchNo);
return ApiRes.ok();
}
......@@ -161,7 +161,7 @@ public class MchInfoController extends CommonCtrl {
// 推送mq删除redis用户认证信息
if (!removeCacheUserIdList.isEmpty()) {
mqServiceImpl.sendUserRemove(removeCacheUserIdList);
mqSendServiceImpl.sendUserRemove(removeCacheUserIdList);
}
//更新商户信息
......@@ -170,7 +170,7 @@ public class MchInfoController extends CommonCtrl {
}
// 推送mq到目前节点进行更新数据
mqServiceImpl.sendModifyMchInfo(mchNo);
mqSendServiceImpl.sendModifyMchInfo(mchNo);
return ApiRes.ok();
}
......
......@@ -23,7 +23,7 @@ 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.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqServiceImpl;
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,7 +45,7 @@ import java.util.List;
public class MchPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MqServiceImpl mqServiceImpl;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MchAppService mchAppService;
/**
......@@ -124,7 +124,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "配置失败");
}
mqServiceImpl.sendModifyMchApp(mchApp.getMchNo(), infoId); // 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyMchApp(mchApp.getMchNo(), infoId); // 推送mq到目前节点进行更新数据
return ApiRes.ok();
}
......
......@@ -23,7 +23,7 @@ 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.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.mq.service.MqServiceImpl;
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 +45,7 @@ import org.springframework.web.bind.annotation.RestController;
public class MchNotifyController extends CommonCtrl {
@Autowired private MchNotifyRecordService mchNotifyService;
@Autowired private MqServiceImpl mqServiceImpl;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
/**
* @author: pangxiaoyu
......@@ -106,7 +106,7 @@ public class MchNotifyController extends CommonCtrl {
mchNotifyService.getBaseMapper().updateIngAndAddNotifyCountLimit(notifyId);
//调起MQ重发
mqServiceImpl.sendPayOrderNotify(notifyId+"");
mqSendServiceImpl.sendPayOrderNotify(notifyId+"");
return ApiRes.ok(mchNotify);
}
......
......@@ -30,7 +30,7 @@ import java.util.Collection;
*/
@Slf4j
@Service
public class MqServiceImpl {
public class MqSendServiceImpl {
@Autowired private MqMchUserRemoveService mqMchUserRemoveService;
@Autowired private MqPayOrderNotifyService mqPayOrderNotifyService;
......
......@@ -17,6 +17,7 @@ package com.jeequan.jeepay.mgr.mq.topic;
import com.jeequan.jeepay.core.constants.CS;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -31,6 +32,7 @@ import org.springframework.context.annotation.Profile;
*/
@Profile(CS.MQTYPE.RABBIT_MQ)
@Configuration
@EnableRabbit
public class RabbitMqConfig {
@Bean("modifyIsvInfo")
......@@ -48,10 +50,9 @@ public class RabbitMqConfig {
@Bean("modifySysConfig")
public Queue modifySysConfig() {
return new Queue(CS.MQ.TOPIC_MODIFY_SYS_CONFIG,true);
return new Queue(CS.MQ.FANOUT_MODIFY_SYS_CONFIG,true);
}
@Bean("payOrderMchNotify")
public Queue payOrderMchNotify() {
return new Queue(CS.MQ.QUEUE_PAYORDER_MCH_NOTIFY,true);
......@@ -62,10 +63,10 @@ public class RabbitMqConfig {
return new Queue(CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE,true);
}
//Topic交换机 起名:topicExchange
@Bean("topicExchange")
TopicExchange topicExchange() {
return new TopicExchange(CS.TOPIC_EXCHANGE,true,false);
//Fanout交换机 起名:fanoutExchange
@Bean("fanoutExchange")
FanoutExchange fanoutExchange() {
return new FanoutExchange(CS.FANOUT_EXCHANGE_SYS_CONFIG,true,false);
}
//交换机 起名:directExchange
......@@ -74,29 +75,28 @@ public class RabbitMqConfig {
return new DirectExchange(CS.DIRECT_EXCHANGE,true,false);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键:TOPIC_MODIFY_ISV_INFO
@Bean
Binding bindingIsvInfo(@Qualifier("modifyIsvInfo") Queue modifyIsvInfo, @Qualifier("topicExchange") TopicExchange topicExchange) {
return BindingBuilder.bind(modifyIsvInfo).to(topicExchange).with(CS.MQ.TOPIC_MODIFY_ISV_INFO);
Binding bindingIsvInfo(@Qualifier("modifyIsvInfo") Queue modifyIsvInfo, @Qualifier("directExchange") DirectExchange directExchange) {
return BindingBuilder.bind(modifyIsvInfo).to(directExchange).with(CS.MQ.TOPIC_MODIFY_ISV_INFO);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键:TOPIC_MODIFY_MCH_APP
@Bean
Binding bindingMchApp(@Qualifier("modifyMchApp") Queue modifyMchApp, @Qualifier("topicExchange") TopicExchange topicExchange) {
return BindingBuilder.bind(modifyMchApp).to(topicExchange).with(CS.MQ.TOPIC_MODIFY_MCH_APP);
Binding bindingMchApp(@Qualifier("modifyMchApp") Queue modifyMchApp, @Qualifier("directExchange") DirectExchange directExchange) {
return BindingBuilder.bind(modifyMchApp).to(directExchange).with(CS.MQ.TOPIC_MODIFY_MCH_APP);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键:TOPIC_MODIFY_MCH_INFO
@Bean
Binding bindingMchInfo(@Qualifier("modifyMchInfo") Queue modifyMchInfo, @Qualifier("topicExchange") TopicExchange topicExchange) {
return BindingBuilder.bind(modifyMchInfo).to(topicExchange).with(CS.MQ.TOPIC_MODIFY_MCH_INFO);
Binding bindingMchInfo(@Qualifier("modifyMchInfo") Queue modifyMchInfo, @Qualifier("directExchange") DirectExchange directExchange) {
return BindingBuilder.bind(modifyMchInfo).to(directExchange).with(CS.MQ.TOPIC_MODIFY_MCH_INFO);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键:TOPIC_MODIFY_SYS_CONFIG
//绑定 将队列和交换机绑定
@Bean
Binding bindingSysConfig(@Qualifier("modifySysConfig") Queue modifySysConfig, @Qualifier("topicExchange") TopicExchange topicExchange) {
return BindingBuilder.bind(modifySysConfig).to(topicExchange).with(CS.MQ.TOPIC_MODIFY_SYS_CONFIG);
Binding bindingSysConfig(Queue modifySysConfig, FanoutExchange fanoutExchange) {
return BindingBuilder.bind(modifySysConfig).to(fanoutExchange);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键:QUEUE_PAYORDER_MCH_NOTIFY
......
......@@ -17,12 +17,9 @@ package com.jeequan.jeepay.mgr.mq.topic;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifyIsvInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
/**
......@@ -34,13 +31,13 @@ import org.springframework.stereotype.Component;
*/
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqTopic4ModifyIsvInfo extends MqModifyIsvInfoService {
public class RabbitMqDirect4ModifyIsvInfo extends MqModifyIsvInfoService {
@Autowired private RabbitTemplate rabbitTemplate;
@Override
public void send(String msg) {
rabbitTemplate.convertAndSend(CS.TOPIC_EXCHANGE, CS.MQ.TOPIC_MODIFY_ISV_INFO, msg);
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_ISV_INFO, msg);
}
}
......@@ -19,12 +19,9 @@ import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.utils.JsonKit;
import com.jeequan.jeepay.mgr.mq.service.MqModifyMchAppService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
/**
......@@ -36,7 +33,7 @@ import org.springframework.stereotype.Component;
*/
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqTopic4ModifyMchApp extends MqModifyMchAppService {
public class RabbitMqDirect4ModifyMchApp extends MqModifyMchAppService {
@Autowired private RabbitTemplate rabbitTemplate;
......@@ -45,7 +42,7 @@ public class RabbitMqTopic4ModifyMchApp extends MqModifyMchAppService {
public void send(String mchNo, String appId) {
JSONObject jsonObject = JsonKit.newJson("mchNo", mchNo);
jsonObject.put("appId", appId);
rabbitTemplate.convertAndSend(CS.TOPIC_EXCHANGE, CS.MQ.TOPIC_MODIFY_ISV_INFO, jsonObject.toString());
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_APP, jsonObject.toString());
}
}
......@@ -31,14 +31,14 @@ import org.springframework.stereotype.Component;
*/
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqTopic4ModifyMchInfo extends MqModifyMchInfoService {
public class RabbitMqDirect4ModifyMchInfo extends MqModifyMchInfoService {
@Autowired private RabbitTemplate rabbitTemplate;
/** 推送消息到各个节点 **/
@Override
public void send(String mchNo) {
rabbitTemplate.convertAndSend(CS.TOPIC_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_INFO, mchNo);
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_INFO, mchNo);
}
}
......@@ -16,15 +16,16 @@
package com.jeequan.jeepay.mgr.mq.topic;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifyMchInfoService;
import com.jeequan.jeepay.mgr.mq.service.MqModifySysConfigService;
import com.jeequan.jeepay.service.impl.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
/**
......@@ -37,15 +38,14 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqTopic4ModifySysConfig extends MqModifySysConfigService {
public class RabbitMqDirect4ModifySysConfig extends MqModifySysConfigService {
@Autowired private RabbitTemplate rabbitTemplate;
@Autowired private AmqpTemplate rabbitTemplate;
@Autowired private SysConfigService sysConfigService;
/** 接收 更新系统配置项的消息 **/
@RabbitListener(queues = CS.MQ.TOPIC_MODIFY_SYS_CONFIG)
@RabbitListener(bindings = {@QueueBinding(value = @Queue(),exchange = @Exchange(name = CS.FANOUT_EXCHANGE_SYS_CONFIG,type = "fanout"))})
public void receive(String msg) {
log.info("成功接收更新系统配置的订阅通知, msg={}", msg);
sysConfigService.initDBConfig(msg);
log.info("系统配置静态属性已重置");
......@@ -54,7 +54,7 @@ public class RabbitMqTopic4ModifySysConfig extends MqModifySysConfigService {
/** 推送消息到各个节点 **/
@Override
public void send(String msg) {
rabbitTemplate.convertAndSend(CS.TOPIC_EXCHANGE, CS.MQ.TOPIC_MODIFY_SYS_CONFIG, msg);
this.rabbitTemplate.convertAndSend(CS.FANOUT_EXCHANGE_SYS_CONFIG, CS.MQ.FANOUT_MODIFY_SYS_CONFIG, msg);
}
}
......@@ -24,7 +24,7 @@ import com.jeequan.jeepay.core.entity.MchApp;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.mch.mq.service.MqServiceImpl;
import com.jeequan.jeepay.mch.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.MchAppService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -43,7 +43,7 @@ import org.springframework.web.bind.annotation.*;
public class MchAppController extends CommonCtrl {
@Autowired private MchAppService mchAppService;
@Autowired private MqServiceImpl mqService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
/**
* @Author: ZhuXiao
......@@ -125,7 +125,7 @@ public class MchAppController extends CommonCtrl {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
// 推送修改应用消息
mqService.sendModifyMchApp(getCurrentMchNo(), mchApp.getAppId());
mqSendServiceImpl.sendModifyMchApp(getCurrentMchNo(), mchApp.getAppId());
return ApiRes.ok();
}
......@@ -147,7 +147,7 @@ public class MchAppController extends CommonCtrl {
mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据
mqService.sendModifyMchApp(getCurrentMchNo(), appId);
mqSendServiceImpl.sendModifyMchApp(getCurrentMchNo(), appId);
return ApiRes.ok();
}
......
......@@ -23,7 +23,7 @@ import com.jeequan.jeepay.core.entity.PayInterfaceDefine;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.mch.mq.service.MqServiceImpl;
import com.jeequan.jeepay.mch.mq.service.MqSendServiceImpl;
import com.jeequan.jeepay.service.impl.MchInfoService;
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,7 +45,7 @@ import java.util.List;
public class MchPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MqServiceImpl mqService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MchInfoService mchInfoService;
/**
......@@ -125,7 +125,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
throw new BizException("配置失败");
}
mqService.sendModifyMchApp(getCurrentMchNo(), infoId); // 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyMchApp(getCurrentMchNo(), infoId); // 推送mq到目前节点进行更新数据
return ApiRes.ok();
}
......
......@@ -15,18 +15,15 @@
*/
package com.jeequan.jeepay.mch.mq.queue;
import com.alibaba.fastjson.JSONArray;
import com.jeequan.jeepay.core.cache.RedisUtil;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mch.mq.service.MqReceiveServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.List;
/**
* 商户用户登录信息清除
*
......@@ -39,6 +36,9 @@ import java.util.List;
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue {
@Autowired
private MqReceiveServiceImpl mqReceiveServiceImpl;
public MqQueue4ModifyMchUserRemove(){
super(CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE);
}
......@@ -50,27 +50,7 @@ public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue {
*/
@JmsListener(destination = CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE)
public void receive(String userIdStr) {
log.info("成功接收删除商户用户登录的订阅通知, msg={}", userIdStr);
// 字符串转List<Long>
List<Long> userIdList = JSONArray.parseArray(userIdStr, Long.class);
// 删除redis用户缓存
if(userIdList == null || userIdList.isEmpty()){
log.info("用户ID为空");
return ;
}
for (Long sysUserId : userIdList) {
Collection<String> cacheKeyList = RedisUtil.keys(CS.getCacheKeyToken(sysUserId, "*"));
if(cacheKeyList == null || cacheKeyList.isEmpty()){
continue;
}
for (String cacheKey : cacheKeyList) {
// 删除用户Redis信息
RedisUtil.del(cacheKey);
continue;
}
}
log.info("无权限登录用户信息已清除");
mqReceiveServiceImpl.mchUserRemove(userIdStr);
}
......
/*
* 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.mch.mq.queue;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mch.mq.service.MqReceiveServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
/**
* 商户用户登录信息清除
*
* @author pangxiaoyu
* @site https://www.jeepay.vip
* @date 2021-04-27 15:50
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMq4ModifyMchUserRemove {
@Autowired
private MqReceiveServiceImpl mqReceiveServiceImpl;
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:17
* @describe: 接收 商户用户登录信息清除消息
*/
@RabbitListener(queues = CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE)
public void receive(String userIdStr) {
mqReceiveServiceImpl.mchUserRemove(userIdStr);
}
}
......@@ -13,39 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mch.mq.queue;
package com.jeequan.jeepay.mch.mq.service;
import com.alibaba.fastjson.JSONArray;
import com.jeequan.jeepay.core.cache.RedisUtil;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.service.impl.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
/**
* 商户用户登录信息清除
* 处理公共接收消息方法
*
* @author pangxiaoyu
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021-04-27 15:50
* @date 2021/6/25 17:10
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqQueue4ModifyMchUserRemove {
@Service
public class MqReceiveServiceImpl {
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:17
* @describe: 接收 商户用户登录信息清除消息
*/
@RabbitListener(queues = CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE)
public void receive(String userIdStr) {
@Autowired private SysConfigService sysConfigService;
public void mchUserRemove(String userIdStr) {
log.info("成功接收删除商户用户登录的订阅通知, msg={}", userIdStr);
// 字符串转List<Long>
List<Long> userIdList = JSONArray.parseArray(userIdStr, Long.class);
......@@ -68,4 +62,9 @@ public class RabbitMqQueue4ModifyMchUserRemove {
log.info("无权限登录用户信息已清除");
}
public void initDbConfig(String msg) {
log.info("成功接收更新系统配置的订阅通知, msg={}", msg);
sysConfigService.initDBConfig(msg);
log.info("系统配置静态属性已重置");
}
}
......@@ -28,7 +28,7 @@ import org.springframework.stereotype.Service;
*/
@Slf4j
@Service
public class MqServiceImpl {
public class MqSendServiceImpl {
@Autowired private MqModifyMchAppService mqModifyMchAppService;
......
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