Commit 81c94049 authored by xiaoyu's avatar xiaoyu
Browse files

增加RabbitMQ兼容

parent 7d78af1a
/*
* 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);
}
/*
* 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 MqServiceImpl {
@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);
}
}
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
*/ */
package com.jeequan.jeepay.mgr.mq.topic; package com.jeequan.jeepay.mgr.mq.topic;
import com.jeequan.jeepay.core.constants.CS;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory; import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory; import org.springframework.jms.config.JmsListenerContainerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -30,6 +32,7 @@ import javax.jms.ConnectionFactory; ...@@ -30,6 +32,7 @@ import javax.jms.ConnectionFactory;
* @date 2021/6/8 17:10 * @date 2021/6/8 17:10
*/ */
@Component @Component
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class JMSConfig { public class JMSConfig {
/** 新增jmsListenerContainer, 用于接收topic类型的消息 **/ /** 新增jmsListenerContainer, 用于接收topic类型的消息 **/
......
...@@ -16,9 +16,14 @@ ...@@ -16,9 +16,14 @@
package com.jeequan.jeepay.mgr.mq.topic; package com.jeequan.jeepay.mgr.mq.topic;
import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifyIsvInfoService;
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;
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.jms.core.JmsTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -31,17 +36,24 @@ import org.springframework.stereotype.Component; ...@@ -31,17 +36,24 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@Component @Component
public class MqTopic4ModifyIsvInfo extends ActiveMQTopic{ @Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqTopic4ModifyIsvInfo extends MqModifyIsvInfoService {
@Autowired private JmsTemplate jmsTemplate; @Autowired private JmsTemplate jmsTemplate;
public MqTopic4ModifyIsvInfo(){ @Bean("modifyIsvInfo")
super(CS.MQ.TOPIC_MODIFY_ISV_INFO); public ActiveMQTopic mqTopic4ModifyIsvInfo(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_ISV_INFO);
} }
/** 推送消息到各个节点 **/ @Lazy
public void push(String isvNo) { @Autowired
this.jmsTemplate.convertAndSend(this, isvNo); @Qualifier("modifyIsvInfo")
private ActiveMQTopic mqTopic4ModifyIsvInfo;
@Override
public void send(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifyIsvInfo, msg);
} }
} }
...@@ -18,9 +18,14 @@ package com.jeequan.jeepay.mgr.mq.topic; ...@@ -18,9 +18,14 @@ package com.jeequan.jeepay.mgr.mq.topic;
import com.alibaba.fastjson.JSONObject; 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.utils.JsonKit;
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;
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.jms.core.JmsTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -33,20 +38,27 @@ import org.springframework.stereotype.Component; ...@@ -33,20 +38,27 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@Component @Component
public class MqTopic4ModifyMchApp extends ActiveMQTopic{ @Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqTopic4ModifyMchApp extends MqModifyMchAppService {
@Autowired private JmsTemplate jmsTemplate; @Autowired private JmsTemplate jmsTemplate;
public MqTopic4ModifyMchApp(){ @Bean("modifyMchApp")
super(CS.MQ.TOPIC_MODIFY_MCH_APP); public ActiveMQTopic mqTopic4ModifyMchApp(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_MCH_APP);
} }
@Lazy
@Autowired
@Qualifier("modifyMchApp")
private ActiveMQTopic mqTopic4ModifyMchApp;
/** 推送消息到各个节点 **/ /** 推送消息到各个节点 **/
public void push(String mchNo, String appId) { @Override
public void send(String mchNo, String appId) {
JSONObject jsonObject = JsonKit.newJson("mchNo", mchNo); JSONObject jsonObject = JsonKit.newJson("mchNo", mchNo);
jsonObject.put("appId", appId); jsonObject.put("appId", appId);
this.jmsTemplate.convertAndSend(mqTopic4ModifyMchApp, jsonObject.toString());
this.jmsTemplate.convertAndSend(this, jsonObject.toString());
} }
} }
...@@ -16,9 +16,14 @@ ...@@ -16,9 +16,14 @@
package com.jeequan.jeepay.mgr.mq.topic; package com.jeequan.jeepay.mgr.mq.topic;
import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifyMchInfoService;
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;
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.jms.core.JmsTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -31,20 +36,23 @@ import org.springframework.stereotype.Component; ...@@ -31,20 +36,23 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@Component @Component
public class MqTopic4ModifyMchInfo extends ActiveMQTopic{ @Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqTopic4ModifyMchInfo extends MqModifyMchInfoService {
@Autowired private JmsTemplate jmsTemplate; @Autowired private JmsTemplate jmsTemplate;
public MqTopic4ModifyMchInfo(){ @Bean("modifyMchInfo")
super(CS.MQ.TOPIC_MODIFY_MCH_INFO); public ActiveMQTopic mqTopic4ModifyMchInfo(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_MCH_INFO);
} }
/** 推送消息到各个节点 **/ @Lazy
public void push(String mchNo) { @Autowired
this.jmsTemplate.convertAndSend(this, mchNo); @Qualifier("modifyMchInfo")
} private ActiveMQTopic mqTopic4ModifyMchInfo;
@Override
public void send(String mchNo) {
this.jmsTemplate.convertAndSend(mqTopic4ModifyMchInfo, mchNo);
}
} }
...@@ -16,10 +16,15 @@ ...@@ -16,10 +16,15 @@
package com.jeequan.jeepay.mgr.mq.topic; package com.jeequan.jeepay.mgr.mq.topic;
import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.mgr.mq.service.MqModifySysConfigService;
import com.jeequan.jeepay.service.impl.SysConfigService; import com.jeequan.jeepay.service.impl.SysConfigService;
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;
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.annotation.JmsListener; import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -33,15 +38,22 @@ import org.springframework.stereotype.Component; ...@@ -33,15 +38,22 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@Component @Component
public class MqTopic4ModifySysConfig extends ActiveMQTopic{ @Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqTopic4ModifySysConfig extends MqModifySysConfigService {
@Autowired private JmsTemplate jmsTemplate; @Autowired private JmsTemplate jmsTemplate;
@Autowired private SysConfigService sysConfigService; @Autowired private SysConfigService sysConfigService;
public MqTopic4ModifySysConfig(){ @Bean("modifySysConfig")
super(CS.MQ.TOPIC_MODIFY_SYS_CONFIG); public ActiveMQTopic mqTopic4ModifySysConfig(){
return new ActiveMQTopic(CS.MQ.TOPIC_MODIFY_SYS_CONFIG);
} }
@Lazy
@Autowired
@Qualifier("modifySysConfig")
private ActiveMQTopic mqTopic4ModifySysConfig;
/** 接收 更新系统配置项的消息 **/ /** 接收 更新系统配置项的消息 **/
@JmsListener(destination = CS.MQ.TOPIC_MODIFY_SYS_CONFIG, containerFactory = "jmsListenerContainer") @JmsListener(destination = CS.MQ.TOPIC_MODIFY_SYS_CONFIG, containerFactory = "jmsListenerContainer")
public void receive(String msg) { public void receive(String msg) {
...@@ -52,8 +64,9 @@ public class MqTopic4ModifySysConfig extends ActiveMQTopic{ ...@@ -52,8 +64,9 @@ public class MqTopic4ModifySysConfig extends ActiveMQTopic{
} }
/** 推送消息到各个节点 **/ /** 推送消息到各个节点 **/
public void push(String msg) { @Override
this.jmsTemplate.convertAndSend(this, msg); public void send(String msg) {
this.jmsTemplate.convertAndSend(mqTopic4ModifySysConfig, 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 org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
/**
* RabbitMq
* 队列交换机注册
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Profile(CS.MQTYPE.RABBIT_MQ)
@Configuration
public class RabbitMqConfig {
@Bean("modifyIsvInfo")
public Queue modifyIsvInfo() { return new Queue(CS.MQ.TOPIC_MODIFY_ISV_INFO,true); }
@Bean("modifyMchApp")
public Queue modifyMchApp() {
return new Queue(CS.MQ.TOPIC_MODIFY_MCH_APP,true);
}
@Bean("modifyMchInfo")
public Queue modifyMchInfo() {
return new Queue(CS.MQ.TOPIC_MODIFY_MCH_INFO,true);
}
@Bean("modifySysConfig")
public Queue modifySysConfig() {
return new Queue(CS.MQ.TOPIC_MODIFY_SYS_CONFIG,true);
}
@Bean("payOrderMchNotify")
public Queue payOrderMchNotify() {
return new Queue(CS.MQ.QUEUE_PAYORDER_MCH_NOTIFY,true);
}
@Bean("mchUserRemove")
public Queue mchUserRemove() {
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);
}
//交换机 起名:directExchange
@Bean("directExchange")
DirectExchange directExchange() {
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);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键: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);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键: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);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键: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);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键:QUEUE_PAYORDER_MCH_NOTIFY
@Bean
Binding bindingPayOrderMchNotify(@Qualifier("payOrderMchNotify") Queue payOrderMchNotify, @Qualifier("directExchange") DirectExchange directExchange) {
return BindingBuilder.bind(payOrderMchNotify).to(directExchange).with(CS.MQ.QUEUE_PAYORDER_MCH_NOTIFY);
}
//绑定 将队列和交换机绑定, 并设置用于匹配键:QUEUE_MODIFY_MCH_USER_REMOVE
@Bean
Binding bindingMchUserRemove(@Qualifier("mchUserRemove") Queue mchUserRemove, @Qualifier("directExchange") DirectExchange directExchange) {
return BindingBuilder.bind(mchUserRemove).to(directExchange).with(CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE);
}
}
/*
* 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.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;
/**
* RabbitMq
* 服务商信息修改推送
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqTopic4ModifyIsvInfo extends MqModifyIsvInfoService {
@Autowired private RabbitTemplate rabbitTemplate;
@Override
public void send(String msg) {
rabbitTemplate.convertAndSend(CS.TOPIC_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 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;
/**
* RabbitMq
* 商户应用修改推送
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqTopic4ModifyMchApp 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.TOPIC_EXCHANGE, CS.MQ.TOPIC_MODIFY_ISV_INFO, 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 RabbitMqTopic4ModifyMchInfo extends MqModifyMchInfoService {
@Autowired private RabbitTemplate rabbitTemplate;
/** 推送消息到各个节点 **/
@Override
public void send(String mchNo) {
rabbitTemplate.convertAndSend(CS.TOPIC_EXCHANGE, CS.MQ.TOPIC_MODIFY_MCH_INFO, 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.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.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;
/**
* RabbitMq
* 系统信息修改推送
* @author xiaoyu
* @site https://www.jeepay.vip
* @date 2021/6/25 17:10
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqTopic4ModifySysConfig extends MqModifySysConfigService {
@Autowired private RabbitTemplate rabbitTemplate;
@Autowired private SysConfigService sysConfigService;
/** 接收 更新系统配置项的消息 **/
@RabbitListener(queues = CS.MQ.TOPIC_MODIFY_SYS_CONFIG)
public void receive(String msg) {
log.info("成功接收更新系统配置的订阅通知, msg={}", msg);
sysConfigService.initDBConfig(msg);
log.info("系统配置静态属性已重置");
}
/** 推送消息到各个节点 **/
@Override
public void send(String msg) {
rabbitTemplate.convertAndSend(CS.TOPIC_EXCHANGE, CS.MQ.TOPIC_MODIFY_SYS_CONFIG, msg);
}
}
...@@ -51,8 +51,8 @@ spring: ...@@ -51,8 +51,8 @@ spring:
database: 1 #1库:运营平台 #2库:商户系统 #3库:支付网关 database: 1 #1库:运营平台 #2库:商户系统 #3库:支付网关
password: password:
#activeMQ配置 #activeMQ配置
activemq: # activemq:
broker-url: tcp://localhost:61616 #连接地址 # broker-url: tcp://localhost:61616 #连接地址
#日志配置参数。 #日志配置参数。
# 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。 # 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。
......
...@@ -89,6 +89,12 @@ ...@@ -89,6 +89,12 @@
<artifactId>spring-boot-starter-activemq</artifactId> <artifactId>spring-boot-starter-activemq</artifactId>
</dependency> </dependency>
<!-- 添加对rabbitMQ的支持 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- 引入 jeepay-sdk-java --> <!-- 引入 jeepay-sdk-java -->
<dependency> <dependency>
<groupId>com.jeequan</groupId> <groupId>com.jeequan</groupId>
......
...@@ -24,9 +24,8 @@ import com.jeequan.jeepay.core.entity.MchApp; ...@@ -24,9 +24,8 @@ 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.mch.ctrl.CommonCtrl; import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.mch.mq.topic.MqTopic4ModifyMchApp; import com.jeequan.jeepay.mch.mq.service.MqServiceImpl;
import com.jeequan.jeepay.service.impl.MchAppService; import com.jeequan.jeepay.service.impl.MchAppService;
import com.jeequan.jeepay.service.impl.MchInfoService;
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;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -44,7 +43,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -44,7 +43,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 MqTopic4ModifyMchApp mqTopic4ModifyMchApp; @Autowired private MqServiceImpl mqService;
/** /**
* @Author: ZhuXiao * @Author: ZhuXiao
...@@ -126,7 +125,7 @@ public class MchAppController extends CommonCtrl { ...@@ -126,7 +125,7 @@ public class MchAppController extends CommonCtrl {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE); return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
} }
// 推送修改应用消息 // 推送修改应用消息
mqTopic4ModifyMchApp.push(getCurrentMchNo(), mchApp.getAppId()); mqService.sendModifyMchApp(getCurrentMchNo(), mchApp.getAppId());
return ApiRes.ok(); return ApiRes.ok();
} }
...@@ -148,7 +147,7 @@ public class MchAppController extends CommonCtrl { ...@@ -148,7 +147,7 @@ public class MchAppController extends CommonCtrl {
mchAppService.removeByAppId(appId); mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据 // 推送mq到目前节点进行更新数据
mqTopic4ModifyMchApp.push(getCurrentMchNo(), appId); mqService.sendModifyMchApp(getCurrentMchNo(), appId);
return ApiRes.ok(); return ApiRes.ok();
} }
......
...@@ -23,7 +23,7 @@ import com.jeequan.jeepay.core.entity.PayInterfaceDefine; ...@@ -23,7 +23,7 @@ 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.mch.ctrl.CommonCtrl; import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.mch.mq.topic.MqTopic4ModifyMchApp; import com.jeequan.jeepay.mch.mq.service.MqServiceImpl;
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,7 +45,7 @@ import java.util.List; ...@@ -45,7 +45,7 @@ import java.util.List;
public class MchPayInterfaceConfigController extends CommonCtrl { public class MchPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService; @Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MqTopic4ModifyMchApp mqTopic4ModifyMchApp; @Autowired private MqServiceImpl mqService;
@Autowired private MchInfoService mchInfoService; @Autowired private MchInfoService mchInfoService;
/** /**
...@@ -125,7 +125,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl { ...@@ -125,7 +125,7 @@ public class MchPayInterfaceConfigController extends CommonCtrl {
throw new BizException("配置失败"); throw new BizException("配置失败");
} }
mqTopic4ModifyMchApp.push(getCurrentMchNo(), infoId); // 推送mq到目前节点进行更新数据 mqService.sendModifyMchApp(getCurrentMchNo(), infoId); // 推送mq到目前节点进行更新数据
return ApiRes.ok(); return ApiRes.ok();
} }
......
...@@ -20,16 +20,15 @@ import com.jeequan.jeepay.core.cache.RedisUtil; ...@@ -20,16 +20,15 @@ import com.jeequan.jeepay.core.cache.RedisUtil;
import com.jeequan.jeepay.core.constants.CS; import com.jeequan.jeepay.core.constants.CS;
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.context.annotation.Profile;
import org.springframework.jms.annotation.JmsListener; import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 更新商户配置mq * 商户用户登录信息清除
* *
* @author pangxiaoyu * @author pangxiaoyu
* @site https://www.jeepay.vip * @site https://www.jeepay.vip
...@@ -37,6 +36,7 @@ import java.util.stream.Collectors; ...@@ -37,6 +36,7 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Component @Component
@Profile(CS.MQTYPE.ACTIVE_MQ)
public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue { public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue {
public MqQueue4ModifyMchUserRemove(){ public MqQueue4ModifyMchUserRemove(){
...@@ -46,7 +46,7 @@ public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue { ...@@ -46,7 +46,7 @@ public class MqQueue4ModifyMchUserRemove extends ActiveMQQueue {
/** /**
* @author: pangxiaoyu * @author: pangxiaoyu
* @date: 2021/6/7 16:17 * @date: 2021/6/7 16:17
* @describe: 接收 更新系统配置项的消息 * @describe: 接收 商户用户登录信息清除消息
*/ */
@JmsListener(destination = CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE) @JmsListener(destination = CS.MQ.QUEUE_MODIFY_MCH_USER_REMOVE)
public void receive(String userIdStr) { public void receive(String 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.alibaba.fastjson.JSONArray;
import com.jeequan.jeepay.core.cache.RedisUtil;
import com.jeequan.jeepay.core.constants.CS;
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 java.util.Collection;
import java.util.List;
/**
* 商户用户登录信息清除
*
* @author pangxiaoyu
* @site https://www.jeepay.vip
* @date 2021-04-27 15:50
*/
@Slf4j
@Component
@Profile(CS.MQTYPE.RABBIT_MQ)
public class RabbitMqQueue4ModifyMchUserRemove {
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:17
* @describe: 接收 商户用户登录信息清除消息
*/
@RabbitListener(queues = 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("无权限登录用户信息已清除");
}
}
/*
* 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);
}
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