mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-04 03:26:31 +00:00
feat: EasyRetry-v3.2.0 => SnailJob-v1.0.0-beta1
This commit is contained in:
@@ -28,21 +28,16 @@
|
||||
<artifactId>spring-cloud-commons</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- EasyRetry Client -->
|
||||
<!-- SnailJob Client -->
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>easy-retry-client-starter</artifactId>
|
||||
<version>${easyretry.version}</version>
|
||||
<artifactId>snail-job-client-starter</artifactId>
|
||||
<version>${snailjob.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>easy-retry-client-core</artifactId>
|
||||
<version>${easyretry.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>easy-retry-client-job-core</artifactId>
|
||||
<version>${easyretry.version}</version>
|
||||
<artifactId>snail-job-client-job-core</artifactId>
|
||||
<version>${snailjob.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@@ -4,12 +4,12 @@ import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.aizuda.easy.retry.client.common.appender.EasyRetryLogbackAppender;
|
||||
import com.aizuda.easy.retry.client.common.event.ChannelReconnectEvent;
|
||||
import com.aizuda.easy.retry.client.common.event.EasyRetryStartingEvent;
|
||||
import com.aizuda.easy.retry.client.starter.EnableEasyRetry;
|
||||
import com.aizuda.snailjob.client.common.appender.SnailLogbackAppender;
|
||||
import com.aizuda.snailjob.client.common.event.SnailChannelReconnectEvent;
|
||||
import com.aizuda.snailjob.client.common.event.SnailClientStartingEvent;
|
||||
import com.aizuda.snailjob.client.starter.EnableSnailJob;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.job.config.properties.EasyRetryServerProperties;
|
||||
import org.dromara.common.job.config.properties.SnailJobServerProperties;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
@@ -29,27 +29,27 @@ import java.util.List;
|
||||
* @since 2024/3/12
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@EnableConfigurationProperties(EasyRetryServerProperties.class)
|
||||
@ConditionalOnProperty(prefix = "easy-retry", name = "enabled", havingValue = "true")
|
||||
@EnableConfigurationProperties(SnailJobServerProperties.class)
|
||||
@ConditionalOnProperty(prefix = "snail-job", name = "enabled", havingValue = "true")
|
||||
@EnableScheduling
|
||||
@EnableEasyRetry(group = "${easy-retry.group-name}")
|
||||
public class EasyRetryConfig {
|
||||
@EnableSnailJob(group = "${snail-job.group-name}")
|
||||
public class SnailJobConfig {
|
||||
|
||||
@Autowired
|
||||
private EasyRetryServerProperties properties;
|
||||
private SnailJobServerProperties properties;
|
||||
@Autowired
|
||||
private DiscoveryClient discoveryClient;
|
||||
|
||||
@EventListener(EasyRetryStartingEvent.class)
|
||||
public void onStarting(EasyRetryStartingEvent event) {
|
||||
@EventListener(SnailClientStartingEvent.class)
|
||||
public void onStarting(SnailClientStartingEvent event) {
|
||||
// 从 nacos 获取 server 服务连接
|
||||
registerServer();
|
||||
// 注册 日志监控配置
|
||||
registerLogging();
|
||||
}
|
||||
|
||||
@EventListener(ChannelReconnectEvent.class)
|
||||
public void onReconnect(ChannelReconnectEvent event) {
|
||||
@EventListener(SnailChannelReconnectEvent.class)
|
||||
public void onReconnect(SnailChannelReconnectEvent event) {
|
||||
// 连接中断 重新从 nacos 获取存活的服务连接(高可用配置)
|
||||
registerServer();
|
||||
}
|
||||
@@ -60,16 +60,16 @@ public class EasyRetryConfig {
|
||||
List<ServiceInstance> instances = discoveryClient.getInstances(serverName);
|
||||
if (CollUtil.isNotEmpty(instances)) {
|
||||
ServiceInstance instance = instances.get(0);
|
||||
System.setProperty("easy-retry.server.host", instance.getHost());
|
||||
System.setProperty("easy-retry.server.port", properties.getPort());
|
||||
System.setProperty("snail-job.server.host", instance.getHost());
|
||||
System.setProperty("snail-job.server.port", properties.getPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerLogging() {
|
||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
EasyRetryLogbackAppender<ILoggingEvent> ca = new EasyRetryLogbackAppender<>();
|
||||
ca.setName("easy_log_appender");
|
||||
SnailLogbackAppender<ILoggingEvent> ca = new SnailLogbackAppender<>();
|
||||
ca.setName("snail_log_appender");
|
||||
ca.start();
|
||||
Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||
rootLogger.addAppender(ca);
|
@@ -4,8 +4,8 @@ import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "easy-retry.server")
|
||||
public class EasyRetryServerProperties {
|
||||
@ConfigurationProperties(prefix = "snail-job.server")
|
||||
public class SnailJobServerProperties {
|
||||
|
||||
private String serverName;
|
||||
|
@@ -1 +1 @@
|
||||
org.dromara.common.job.config.EasyRetryConfig
|
||||
org.dromara.common.job.config.SnailJobConfig
|
||||
|
Reference in New Issue
Block a user