| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package jnpf.config;
- import com.baomidou.lock.LockTemplate;
- import jnpf.consts.ProjectEventConst;
- import jnpf.handler.ProjectEventMQMessageHandler;
- import jnpf.handler.ProjectEventMQSender;
- import jnpf.properties.EventProperty;
- import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
- import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
- import org.springframework.cloud.stream.function.StreamBridge;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.messaging.Message;
- import java.util.function.Consumer;
- @Configuration(proxyBeanMethods = false)
- public class MqAutoConfiguration {
- @Bean(ProjectEventConst.DEFAULT_TOPIC_NAME)
- @ConditionalOnProperty(prefix = "event", name = "event-publish-type", havingValue = ProjectEventConst.EVENT_PUBLISH_TYPE_QUEUE)
- public Consumer<Message<?>> getDefaultMqConsumer(LockTemplate lockTemplate){
- return new ProjectEventMQMessageHandler(lockTemplate);
- }
- /**
- * 自定义事件发布渠道为QUEUE
- */
- @Bean
- @ConditionalOnProperty(prefix = "event", name = "event-publish-type", havingValue = ProjectEventConst.EVENT_PUBLISH_TYPE_QUEUE)
- public ProjectEventMQSender getProjectEventMQSender(StreamBridge streamBridge, EventProperty eventProperties){
- return new ProjectEventMQSender(streamBridge, eventProperties);
- }
- /**
- * 单点用户同步默认空处理器
- */
- @Bean("ssoEventReceiver")
- @ConditionalOnMissingBean(name = "ssoEventReceiver")
- public Consumer<Message<?>> getDefaultSsoConsumer(){
- return (message)->{};
- }
- }
|