diff --git a/alis-boot/alis-node/pom.xml b/alis-boot/alis-node/pom.xml index b4b7262..6fb3c8f 100644 --- a/alis-boot/alis-node/pom.xml +++ b/alis-boot/alis-node/pom.xml @@ -4,16 +4,16 @@ org.alis.boot alis-boot medusa - + alis-node alis-node node - + 11 - + org.springframework.boot @@ -86,8 +86,8 @@ true - - + + diff --git a/alis-boot/alis-node/src/main/java/org/alis/boot/alisboot/AlisBootApplication.java b/alis-boot/alis-node/src/main/java/org/alis/boot/alisboot/AlisBootApplication.java index ec707bd..bd92bda 100644 --- a/alis-boot/alis-node/src/main/java/org/alis/boot/alisboot/AlisBootApplication.java +++ b/alis-boot/alis-node/src/main/java/org/alis/boot/alisboot/AlisBootApplication.java @@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; /** - * spring boot 深度理解 + * spring boot 深度理解 * @classname AlisBootApplication * @author smallcc * @date 2020/11/23 19:31 diff --git a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/SpringApplicationBoots.java b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/SpringApplicationBoots.java index 1950ad4..e085e47 100644 --- a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/SpringApplicationBoots.java +++ b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/SpringApplicationBoots.java @@ -8,14 +8,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; /** - * + * * 引导类 - * @author Administrator + * @author Administrator * */ public class SpringApplicationBoots { - + public static void main(String[] args) { SpringApplication app = new SpringApplication(); app.setSources(Collections.singleton(ApplicationConfiguration.class.getName())); @@ -24,7 +24,7 @@ public class SpringApplicationBoots { ApplicationConfiguration bean = context.getBean(ApplicationConfiguration.class); System.out.println(bean.getClass().getSimpleName()); } - + @SpringBootApplication public static class ApplicationConfiguration{} } diff --git a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/SpringApplicationContextBootStrap.java b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/SpringApplicationContextBootStrap.java index a179d12..9198a16 100644 --- a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/SpringApplicationContextBootStrap.java +++ b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/SpringApplicationContextBootStrap.java @@ -4,10 +4,10 @@ import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ConfigurableApplicationContext; /** - * - * + * + * * Spring 应用上下文引导类 - * + * * @author Administrator * */ diff --git a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/context/AfterApplicationContextInitializer.java b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/context/AfterApplicationContextInitializer.java index d416175..dd87f8b 100644 --- a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/context/AfterApplicationContextInitializer.java +++ b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/context/AfterApplicationContextInitializer.java @@ -7,7 +7,7 @@ public class AfterApplicationContextInitializer implements Ordered,ApplicationCo @Override public void initialize(ConfigurableApplicationContext applicationContext) { - + System.out.println("this ok: "+applicationContext.getId()); } diff --git a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/context/AlisApplicationApplicationContextInitializer.java b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/context/AlisApplicationApplicationContextInitializer.java index c2f3486..1359ba2 100644 --- a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/context/AlisApplicationApplicationContextInitializer.java +++ b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/context/AlisApplicationApplicationContextInitializer.java @@ -9,7 +9,7 @@ public class AlisApplicationApplicationContextInitializer implements Application @Override public void initialize(ConfigurableApplicationContext applicationContext) { - + System.out.println("ConfigurableApplicationContext: "+applicationContext.getId()); } diff --git a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/listener/AlisApplicationListener.java b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/listener/AlisApplicationListener.java index b812659..6a1f857 100644 --- a/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/listener/AlisApplicationListener.java +++ b/alis-boot/spring-application/src/main/java/org/alis/boot/alisboot/listener/AlisApplicationListener.java @@ -15,7 +15,7 @@ public class AlisApplicationListener implements ApplicationListener/ - + diff --git a/alis-component/src/main/java/org/alis/aliscomponent/component/config/AbstractConsumer.java b/alis-component/src/main/java/org/alis/aliscomponent/component/config/AbstractConsumer.java index 31c5ad8..6354a42 100644 --- a/alis-component/src/main/java/org/alis/aliscomponent/component/config/AbstractConsumer.java +++ b/alis-component/src/main/java/org/alis/aliscomponent/component/config/AbstractConsumer.java @@ -5,6 +5,7 @@ import cn.hutool.core.thread.ThreadUtil; import java.util.Objects; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** @@ -17,6 +18,9 @@ public abstract class AbstractConsumer { private final Executor executor; + private final ScheduledThreadPoolExecutor scheduledExecutorService; + + public AbstractConsumer(BlockingQueue taskQueue) { this(taskQueue, ThreadUtil.newExecutor()); } @@ -24,10 +28,11 @@ public abstract class AbstractConsumer { public AbstractConsumer(BlockingQueue taskQueue, Executor executor) { this.taskQueue = taskQueue; this.executor = executor; + this.scheduledExecutorService = ThreadUtil.createScheduledExecutor(1); } public void startConsumer() { - executor.execute(() -> { + scheduledExecutorService.scheduleWithFixedDelay(() -> { try { T e; while (Objects.nonNull(e = taskQueue.poll(30L, TimeUnit.SECONDS))) { @@ -38,7 +43,7 @@ public abstract class AbstractConsumer { Thread.currentThread().interrupt(); } - }); + }, 1L, 1L, TimeUnit.SECONDS); } /** diff --git a/alis-component/src/main/java/org/alis/aliscomponent/component/config/AbstractProvider.java b/alis-component/src/main/java/org/alis/aliscomponent/component/config/AbstractProvider.java index 8fd98c7..b1fcc8e 100644 --- a/alis-component/src/main/java/org/alis/aliscomponent/component/config/AbstractProvider.java +++ b/alis-component/src/main/java/org/alis/aliscomponent/component/config/AbstractProvider.java @@ -30,7 +30,7 @@ public abstract class AbstractProvider { } public void startProvide() { - scheduledExecutorService.scheduleAtFixedRate(() -> executor.execute(() -> { + scheduledExecutorService.scheduleWithFixedDelay(() -> executor.execute(() -> { try { taskQueue.offer(provide(), 30L, TimeUnit.SECONDS); } catch (InterruptedException e) {