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