🐎 WebSocket推送优化,异步推送&当无邮件配置时不进行邮件推送
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
package com.hccake.ballcat.admin;
|
||||
|
||||
import com.hccake.ballcat.admin.modules.notify.push.MailNotifyPusher;
|
||||
import com.hccake.ballcat.admin.modules.sys.checker.AdminRuleProperties;
|
||||
import com.hccake.ballcat.admin.oauth.UserInfoCoordinator;
|
||||
import com.hccake.ballcat.common.mail.MailAutoConfiguration;
|
||||
import com.hccake.ballcat.common.mail.sender.MailSender;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
@@ -18,7 +23,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
@MapperScan("com.hccake.ballcat.**.mapper")
|
||||
@ComponentScan
|
||||
@ServletComponentScan("com.hccake.ballcat.admin.oauth.filter")
|
||||
@Configuration
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AutoConfigureAfter(MailAutoConfiguration.class)
|
||||
@EnableConfigurationProperties(AdminRuleProperties.class)
|
||||
public class UpmsAutoConfiguration {
|
||||
|
||||
@@ -28,4 +34,10 @@ public class UpmsAutoConfiguration {
|
||||
return new UserInfoCoordinator();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(MailSender.class)
|
||||
public MailNotifyPusher mailNotifyPusher(MailSender mailSender) {
|
||||
return new MailNotifyPusher(mailSender);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.hccake.ballcat.admin.modules.notify.push.NotifyPushExecutor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -25,6 +26,7 @@ public class NotifyPublishEventListener {
|
||||
* 通知发布事件
|
||||
* @param event the NotifyPublishEvent
|
||||
*/
|
||||
@Async
|
||||
@EventListener(NotifyPublishEvent.class)
|
||||
public void onNotifyPublishEvent(NotifyPublishEvent event) {
|
||||
NotifyInfo notifyInfo = event.getNotifyInfo();
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.hccake.ballcat.admin.modules.sys.model.entity.SysUser;
|
||||
import com.hccake.ballcat.common.mail.model.MailDetails;
|
||||
import com.hccake.ballcat.common.mail.sender.MailSender;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,7 +15,6 @@ import java.util.List;
|
||||
* @author Hccake 2020/12/21
|
||||
* @version 1.0
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MailNotifyPusher implements NotifyPusher {
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class NotifyPushExecutor {
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("push notify error in channel:[{}],notifyInfo title:[{}]", notifyChannel,
|
||||
notifyInfo.getTitle());
|
||||
notifyInfo.getTitle(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ import com.hccake.ballcat.admin.websocket.message.DictChangeMessage;
|
||||
import com.hccake.ballcat.common.core.util.JacksonUtils;
|
||||
import com.hccake.ballcat.common.websocket.WebSocketMessageSender;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -24,6 +26,7 @@ import java.util.List;
|
||||
* @author Hccake 2021/1/5
|
||||
* @version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class PushEventListener {
|
||||
@@ -34,6 +37,7 @@ public class PushEventListener {
|
||||
* 字典修改事件监听
|
||||
* @param event the DictChangeEvent
|
||||
*/
|
||||
@Async
|
||||
@EventListener(DictChangeEvent.class)
|
||||
public void onDictChangeEvent(DictChangeEvent event) {
|
||||
// 构建字典修改的消息体
|
||||
@@ -49,6 +53,7 @@ public class PushEventListener {
|
||||
* 公告关闭事件监听
|
||||
* @param event the AnnouncementCloseEvent
|
||||
*/
|
||||
@Async
|
||||
@EventListener(AnnouncementCloseEvent.class)
|
||||
public void onAnnouncementCloseEvent(AnnouncementCloseEvent event) {
|
||||
// 构建字典修改的消息体
|
||||
@@ -64,6 +69,7 @@ public class PushEventListener {
|
||||
* 站内通知推送事件
|
||||
* @param event the StationNotifyPushEvent
|
||||
*/
|
||||
@Async
|
||||
@EventListener(StationNotifyPushEvent.class)
|
||||
public void onAnnouncementPublishEvent(StationNotifyPushEvent event) {
|
||||
NotifyInfo notifyInfo = event.getNotifyInfo();
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @author lingting 2020-10-13 22:39
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "ballcat")
|
||||
public class MonitorProperties {
|
||||
|
||||
|
||||
@@ -2,13 +2,11 @@ package com.hccake.ballcat.common.conf.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lingting 2020-10-13 22:39
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "ballcat.security")
|
||||
public class SecurityProperties {
|
||||
|
||||
|
||||
@@ -14,14 +14,12 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
/**
|
||||
* @author Hccake
|
||||
* @version 1.0
|
||||
* @date 2019/10/15 18:20
|
||||
*/
|
||||
@EnableAsync
|
||||
@RequiredArgsConstructor
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class ExceptionHandleAutoConfiguration {
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.hccake.ballcat.common.conf.web;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.hccake.ballcat.common.conf.config.MonitorProperties;
|
||||
import com.hccake.ballcat.common.conf.config.SecurityProperties;
|
||||
import com.hccake.ballcat.common.core.filter.ActuatorAuthFilter;
|
||||
import com.hccake.ballcat.common.core.filter.XSSFilter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -17,7 +19,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @date 2019/10/17 20:26
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({ SecurityProperties.class, MonitorProperties.class })
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnWebApplication
|
||||
public class FilterConfig {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.hccake.ballcat.common.conf.web;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@@ -11,6 +12,7 @@ import java.util.List;
|
||||
* @version 1.0
|
||||
* @date 2019/10/19 17:10
|
||||
*/
|
||||
@EnableAsync
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
|
||||
@@ -4,7 +4,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.hccake.ballcat.common.conf.exception.ExceptionHandleAutoConfiguration,\
|
||||
com.hccake.ballcat.common.conf.mybatis.MybatisPlusConfig,\
|
||||
com.hccake.ballcat.common.conf.web.WebMvcConfig,\
|
||||
com.hccake.ballcat.common.conf.config.ExceptionHandleConfig,\
|
||||
com.hccake.ballcat.common.conf.config.SecurityProperties,\
|
||||
com.hccake.ballcat.common.conf.config.MonitorProperties
|
||||
com.hccake.ballcat.common.conf.config.ExceptionHandleConfig
|
||||
|
||||
|
||||
@@ -118,6 +118,11 @@
|
||||
<artifactId>ballcat-admin-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hccake</groupId>
|
||||
<artifactId>ballcat-admin-websocket</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hccake</groupId>
|
||||
<artifactId>ballcat-common-conf</artifactId>
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
<groupId>com.hccake</groupId>
|
||||
<artifactId>ballcat-admin-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hccake</groupId>
|
||||
<artifactId>ballcat-admin-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hccake</groupId>
|
||||
<artifactId>ballcat-spring-boot-starter-job</artifactId>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.hccake.ballcat.common.mail;
|
||||
|
||||
import com.hccake.ballcat.common.mail.sender.MailSender;
|
||||
import com.hccake.ballcat.common.mail.sender.MailSenderImpl;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
|
||||
/**
|
||||
* @author Hccake 2021/1/7
|
||||
* @version 1.0
|
||||
*/
|
||||
@AutoConfigureAfter(MailSenderAutoConfiguration.class)
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class MailAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(JavaMailSender.class)
|
||||
@ConditionalOnMissingBean(MailSender.class)
|
||||
public MailSender mailSenderImpl(JavaMailSender javaMailSender,
|
||||
ApplicationEventPublisher applicationEventPublisher) {
|
||||
return new MailSenderImpl(javaMailSender, applicationEventPublisher);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.hccake.ballcat.common.mail.sender.MailSenderImpl
|
||||
com.hccake.ballcat.common.mail.MailAutoConfiguration
|
||||
|
||||
@@ -39,6 +39,6 @@ public class WebSocketProperties {
|
||||
/**
|
||||
* 是否开启对session的映射记录
|
||||
*/
|
||||
private boolean mapSession = false;
|
||||
private boolean mapSession = true;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user