sensitive deal

master
robin(lc) 2 years ago
parent 81afc75dd7
commit 2a8c49db64

@ -4,16 +4,16 @@
<groupId>org.alis.boot</groupId>
<artifactId>alis-boot</artifactId>
<version>medusa</version>
<relativePath/>
<relativePath/>
</parent>
<artifactId>alis-node</artifactId>
<name>alis-node</name>
<description>node</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -86,8 +86,8 @@
<scope>true</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

@ -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

@ -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{}
}

@ -4,10 +4,10 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
/**
*
*
*
*
* Spring
*
*
* @author Administrator
*
*/

@ -7,7 +7,7 @@ public class AfterApplicationContextInitializer implements Ordered,ApplicationCo
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
System.out.println("this ok: "+applicationContext.getId());
}

@ -9,7 +9,7 @@ public class AlisApplicationApplicationContextInitializer implements Application
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
System.out.println("ConfigurableApplicationContext: "+applicationContext.getId());
}

@ -15,7 +15,7 @@ public class AlisApplicationListener implements ApplicationListener<ContextRefre
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
System.out.println("hello event :"+event.getApplicationContext().getId()+" timestamp:" +event.getTimestamp());
}
}

@ -51,7 +51,7 @@
<path>/</path>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

@ -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<T> {
private final Executor executor;
private final ScheduledThreadPoolExecutor scheduledExecutorService;
public AbstractConsumer(BlockingQueue<T> taskQueue) {
this(taskQueue, ThreadUtil.newExecutor());
}
@ -24,10 +28,11 @@ public abstract class AbstractConsumer<T> {
public AbstractConsumer(BlockingQueue<T> 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<T> {
Thread.currentThread().interrupt();
}
});
}, 1L, 1L, TimeUnit.SECONDS);
}
/**

@ -30,7 +30,7 @@ public abstract class AbstractProvider<T> {
}
public void startProvide() {
scheduledExecutorService.scheduleAtFixedRate(() -> executor.execute(() -> {
scheduledExecutorService.scheduleWithFixedDelay(() -> executor.execute(() -> {
try {
taskQueue.offer(provide(), 30L, TimeUnit.SECONDS);
} catch (InterruptedException e) {

Loading…
Cancel
Save