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

MQ整体优化

parent 010d8799
/*
* 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 MqPayOrderNotifyService {
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;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
/**
* mq消息中转
*
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Slf4j
@Service
public class MqSendServiceImpl {
@Autowired private MqMchUserRemoveService mqMchUserRemoveService;
@Autowired private MqPayOrderNotifyService mqPayOrderNotifyService;
@Autowired private MqModifyIsvInfoService mqModifyIsvInfoService;
@Autowired private MqModifyMchInfoService mqModifyMchInfoService;
@Autowired private MqModifyMchAppService mqModifyMchAppService;
@Autowired private MqModifySysConfigService mqModifySysConfigService;
/** 删除商户用户信息 **/
public void sendUserRemove(Collection<Long> userIdList){
mqMchUserRemoveService.send(userIdList);
}
/** 订单回调信息 **/
public void sendPayOrderNotify(String msg){
mqPayOrderNotifyService.send(msg);
}
/** 服务商修改推送 **/
public void sendModifyIsvInfo(String msg){ mqModifyIsvInfoService.send(msg); }
/** 商户修改推送 **/
public void sendModifyMchInfo(String msg){ mqModifyMchInfoService.send(msg); }
/** 商户应用修改推送 **/
public void sendModifyMchApp(String mchNo, String appId){
mqModifyMchAppService.send(mchNo, appId);
}
/** 系统配置修改推送 **/
public void sendModifySysConfig(String msg){
mqModifySysConfigService.send(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.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.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;
/*
* 更改ISV信息
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/6/8 17:10
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqTopic4ModifyIsvInfo extends MqModifyIsvInfoService {
@Autowired private JmsTemplate jmsTemplate;
@Bean("activeModifyIsvInfo")
public ActiveMQTopic mqTopic4ModifyIsvInfo(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_ISV_INFO);
}
@Lazy
@Autowired
@Qualifier("activeModifyIsvInfo")
private ActiveMQTopic mqTopic4ModifyIsvInfo;
@Override
public void send(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifyIsvInfo, 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.topic;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifyMchInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
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;
/*
* 更改商户信息
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/6/8 17:10
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqTopic4ModifyMchInfo extends MqModifyMchInfoService {
@Autowired private JmsTemplate jmsTemplate;
@Bean("activeModifyMchInfo")
public ActiveMQTopic mqTopic4ModifyMchInfo(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_MCH_INFO);
}
@Lazy
@Autowired
@Qualifier("activeModifyMchInfo")
private ActiveMQTopic mqTopic4ModifyMchInfo;
@Override
public void send(String mchNo) {
this.jmsTemplate.convertAndSend(mqTopic4ModifyMchInfo, 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.topic;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifyIsvInfoService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
/**
* RabbitMq
* 服务商信息修改推送
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqDirect4ModifyIsvInfo extends MqModifyIsvInfoService {
@Autowired private RabbitTemplate rabbitTemplate;
@Override
public void send(String msg) {
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_ISV_INFO, 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.topic;
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 org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
/**
* RabbitMq
* 商户应用修改推送
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqDirect4ModifyMchApp extends MqModifyMchAppService {
@Autowired private RabbitTemplate rabbitTemplate;
/** 推送消息到各个节点 **/
@Override
public void send(String mchNo, String appId) {
JSONObject jsonObject = JsonKit.newJson("mchNo", mchNo);
jsonObject.put("appId", appId);
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_APP, jsonObject.toString());
}
}
/*
* 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.topic;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifyMchInfoService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
/**
* RabbitMq
* 商户信息修改推送
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqDirect4ModifyMchInfo extends MqModifyMchInfoService {
@Autowired private RabbitTemplate rabbitTemplate;
/** 推送消息到各个节点 **/
@Override
public void send(String mchNo) {
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_INFO, mchNo);
}
}
......@@ -16,15 +16,18 @@
package com.jeequan.jeepay.mch.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.exception.BizException;
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.mch.ctrl.CommonCtrl;
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 +46,7 @@ import org.springframework.web.bind.annotation.*;
public class MchAppController extends CommonCtrl {
@Autowired private MchAppService mchAppService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MqCommonService mqCommonService;
/**
* @Author: ZhuXiao
......@@ -125,7 +128,9 @@ public class MchAppController extends CommonCtrl {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
// 推送修改应用消息
mqSendServiceImpl.sendModifyMchApp(getCurrentMchNo(), 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();
}
......@@ -147,7 +152,9 @@ public class MchAppController extends CommonCtrl {
mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据
mqSendServiceImpl.sendModifyMchApp(getCurrentMchNo(), 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();
}
......
......@@ -15,6 +15,7 @@
*/
package com.jeequan.jeepay.mch.ctrl.merchant;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchInfo;
......@@ -22,8 +23,9 @@ import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
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.core.mq.MqCommonService;
import com.jeequan.jeepay.core.utils.JsonKit;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
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,8 +47,8 @@ import java.util.List;
public class MchPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MqSendServiceImpl mqSendServiceImpl;
@Autowired private MchInfoService mchInfoService;
@Autowired private MqCommonService mqCommonService;
/**
* @Author: ZhuXiao
......@@ -124,8 +126,9 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
if (!result) {
throw new BizException("配置失败");
}
mqSendServiceImpl.sendModifyMchApp(getCurrentMchNo(), infoId); // 推送mq到目前节点进行更新数据
JSONObject jsonObject = JsonKit.newJson("mchNo", getCurrentMchNo());
jsonObject.put("appId", infoId);
mqCommonService.send(jsonObject.toJSONString(), CS.MQ.MQ_TYPE_MODIFY_MCH_APP);
return ApiRes.ok();
}
......
......@@ -13,12 +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.mch.mq;
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 com.jeequan.jeepay.core.mq.MqCommonService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -39,26 +37,36 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqTopic4ModifyMchApp extends MqModifyMchAppService {
public class ActiveMqSend extends MqCommonService {
@Autowired private JmsTemplate jmsTemplate;
@Bean("activeModifyMchApp")
@Bean("activeMqSendModifyMchApp")
public ActiveMQTopic mqTopic4ModifyMchApp(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_MCH_APP);
}
@Lazy
@Autowired
@Qualifier("activeModifyMchApp")
@Qualifier("activeMqSendModifyMchApp")
private ActiveMQTopic mqTopic4ModifyMchApp;
/** 推送消息到各个节点 **/
@Override
public void send(String mchNo, String appId) {
JSONObject jsonObject = JsonKit.newJson("mchNo", mchNo);
jsonObject.put("appId", appId);
this.jmsTemplate.convertAndSend(mqTopic4ModifyMchApp, jsonObject.toString());
public void send(String msg, String sendType) {
if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_MCH_APP)) { // 商户应用修改
topicModifyMchApp(msg);
}
}
@Override
public void send(String msg, long delay, String sendType) {
}
/** 发送商户应用修改信息 **/
public void topicModifyMchApp(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifyMchApp, msg);
}
}
......@@ -13,18 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mch.mq.topic;
package com.jeequan.jeepay.mch.mq;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.utils.JsonKit;
import com.jeequan.jeepay.mch.mq.service.MqModifyMchAppService;
import com.jeequan.jeepay.core.mq.MqCommonService;
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;
/**
......@@ -37,17 +33,25 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqDirect4ModifyMchApp extends MqModifyMchAppService {
public class RabbitMqSend extends MqCommonService {
@Autowired private RabbitTemplate rabbitTemplate;
/** 推送消息到各个节点 **/
/** 推送消息 **/
@Override
public void send(String mchNo, String appId) {
JSONObject jsonObject = JsonKit.newJson("mchNo", mchNo);
jsonObject.put("appId", appId);
public void send(String msg, String sendType) {
if (sendType.equals(CS.MQ.MQ_TYPE_MODIFY_MCH_APP)) { // 商户应用修改
directModifyMchApp(msg);
}
}
@Override
public void send(String msg, long delay, String sendType) {
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_APP, jsonObject.toString());
}
/** 发送商户应用修改信息 **/
public void directModifyMchApp(String msg) {
rabbitTemplate.convertAndSend(CS.DIRECT_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_APP, msg);
}
}
......@@ -13,10 +13,10 @@
* 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.activemq.queue;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mch.mq.service.MqReceiveServiceImpl;
import com.jeequan.jeepay.mch.mq.receive.MqReceiveServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -36,8 +36,7 @@ import org.springframework.stereotype.Component;
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue {
@Autowired
private MqReceiveServiceImpl mqReceiveServiceImpl;
@Autowired private MqReceiveServiceImpl mqReceiveServiceImpl;
public MqQueue4ModifyMchUserRemove(){
super(CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE);
......@@ -53,6 +52,4 @@ public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue {
mqReceiveServiceImpl.mchUserRemove(userIdStr);
}
}
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mch.mq.topic;
package com.jeequan.jeepay.mch.mq.activemq.topic;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mch.mq.service.MqReceiveServiceImpl;
import com.jeequan.jeepay.mch.mq.receive.MqReceiveServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -49,6 +49,4 @@ public class MqTopic4ModifySysConfig extends ActiveMQTopic{
mqReceiveServiceImpl.initDbConfig(msg);
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mch.mq.topic;
package com.jeequan.jeepay.mch.mq.config;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
......
......@@ -13,51 +13,47 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mgr.mq.queue;
package com.jeequan.jeepay.mch.mq.config;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqPayOrderNotifyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
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.Lazy;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
import javax.jms.Queue;
/**
* 商户订单回调MQ通知
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/6/21 18:03
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqQueue4PayOrderMchNotify extends MqPayOrderNotifyService {
* RabbitMq
* 队列交换机注册
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Profile(CS.MQTYPE.RABBIT_MQ)
@Configuration
@EnableRabbit
public class RabbitMqConfig {
@Autowired private JmsTemplate jmsTemplate;
@Bean("activePayOrderMchNotify")
public Queue mqQueue4PayOrderMchNotify(){
return new ActiveMQQueue(CS.MQ.QUEUE_PAYORDER_MCH_NOTIFY);
@Bean("modifyMchApp")
public Queue modifyMchApp() {
return new Queue(CS.MQ.TOPIC_MODIFY_MCH_APP,true);
}
@Lazy
@Autowired
@Qualifier("activePayOrderMchNotify")
private Queue mqQueue4PayOrderMchNotify;
//交换机 起名:directExchange
@Bean("directExchange")
DirectExchange directExchange() {
return new DirectExchange(CS.DIRECT_EXCHANGE,true,false);
}
/** 发送MQ消息 **/
@Override
public void send(String msg) {
this.jmsTemplate.convertAndSend(mqQueue4PayOrderMchNotify, msg);
//绑定 将队列和交换机绑定, 并设置用于匹配键:TOPIC_MODIFY_MCH_APP
@Bean
Binding bindingMchApp(@Qualifier("modifyMchApp") Queue modifyMchApp, @Qualifier("directExchange") DirectExchange directExchange) {
return BindingBuilder.bind(modifyMchApp).to(directExchange).with(CS.MQ.TOPIC_MODIFY_MCH_APP);
}
}
......@@ -13,10 +13,10 @@
* 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.rabbitmq;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mch.mq.service.MqReceiveServiceImpl;
import com.jeequan.jeepay.mch.mq.receive.MqReceiveServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -35,8 +35,7 @@ import org.springframework.stereotype.Component;
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMq4ModifyMchUserRemove {
@Autowired
private MqReceiveServiceImpl mqReceiveServiceImpl;
@Autowired private MqReceiveServiceImpl mqReceiveServiceImpl;
/**
* @author: pangxiaoyu
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mch.mq.topic;
package com.jeequan.jeepay.mch.mq.rabbitmq;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mch.mq.service.MqReceiveServiceImpl;
import com.jeequan.jeepay.mch.mq.receive.MqReceiveServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
......@@ -45,7 +45,4 @@ public class RabbitMqDirect4ModifySysConfig {
public void receive(String msg) {
mqReceiveServiceImpl.initDbConfig(msg);
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.mch.mq.service;
package com.jeequan.jeepay.mch.mq.receive;
import com.alibaba.fastjson.JSONArray;
import com.jeequan.jeepay.core.cache.RedisUtil;
......
/*
* 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.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.mch.mq.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* mq消息中转
*
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Slf4j
@Service
public class MqSendServiceImpl {
@Autowired private MqModifyMchAppService mqModifyMchAppService;
public void sendModifyMchApp(String mchNo, String appId){
mqModifyMchAppService.send(mchNo, appId);
}
}
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