Added wait before waitron send staff event.
Added logging for rabbit
This commit is contained in:
@@ -1,2 +1,5 @@
|
|||||||
spring.application.name=customer
|
spring.application.name=customer
|
||||||
logging.level.root=info
|
logging.level.root=info
|
||||||
|
logging.level.io.spring=debug
|
||||||
|
logging.level.org.springframework.cloud=debug
|
||||||
|
logging.level.com.rabbitmq.client=debug
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
spring.application.name=restaurant
|
spring.application.name=restaurant
|
||||||
|
|
||||||
logging.level.root=info
|
logging.level.root=info
|
||||||
|
logging.level.io.spring=debug
|
||||||
|
logging.level.org.springframework.cloud=debug
|
||||||
|
logging.level.com.rabbitmq.client=debug
|
||||||
@@ -17,8 +17,10 @@ package io.spring.scdf.waitron;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableScheduling
|
||||||
public class ScdfAppWaitronApplication {
|
public class ScdfAppWaitronApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -29,11 +29,14 @@ import org.springframework.cloud.stream.annotation.StreamListener;
|
|||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.env.Profiles;
|
import org.springframework.core.env.Profiles;
|
||||||
|
import org.springframework.core.task.AsyncTaskExecutor;
|
||||||
import org.springframework.messaging.MessageChannel;
|
import org.springframework.messaging.MessageChannel;
|
||||||
import org.springframework.messaging.SubscribableChannel;
|
import org.springframework.messaging.SubscribableChannel;
|
||||||
import org.springframework.messaging.support.MessageBuilder;
|
import org.springframework.messaging.support.MessageBuilder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Corneil du Plessis
|
* @author Corneil du Plessis
|
||||||
*/
|
*/
|
||||||
@@ -44,11 +47,13 @@ public class Waitron {
|
|||||||
private final Events events;
|
private final Events events;
|
||||||
private final ApplicationAvailability applicationAvailability;
|
private final ApplicationAvailability applicationAvailability;
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
private final AsyncTaskExecutor taskExecutor;
|
||||||
|
|
||||||
public Waitron(Events events, ApplicationAvailability applicationAvailability, Environment environment) {
|
public Waitron(Events events, ApplicationAvailability applicationAvailability, Environment environment, AsyncTaskExecutor taskExecutor) {
|
||||||
this.events = events;
|
this.events = events;
|
||||||
this.applicationAvailability = applicationAvailability;
|
this.applicationAvailability = applicationAvailability;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
|
this.taskExecutor = taskExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@StreamListener(Events.PAYMENT)
|
@StreamListener(Events.PAYMENT)
|
||||||
@@ -62,8 +67,12 @@ public class Waitron {
|
|||||||
logger.info("availability:{}:{}", applicationAvailability.getLivenessState(), applicationAvailability.getReadinessState());
|
logger.info("availability:{}:{}", applicationAvailability.getLivenessState(), applicationAvailability.getReadinessState());
|
||||||
if (!environment.acceptsProfiles(Profiles.of("test"))) {
|
if (!environment.acceptsProfiles(Profiles.of("test"))) {
|
||||||
if (LivenessState.CORRECT.equals(applicationAvailability.getLivenessState())) {
|
if (LivenessState.CORRECT.equals(applicationAvailability.getLivenessState())) {
|
||||||
logger.info("onEvent:send:atWork:waitron");
|
taskExecutor.submit((Callable<Object>) () -> {
|
||||||
events.atWork().send(MessageBuilder.withPayload("waitron").build());
|
logger.info("onEvent:wait");
|
||||||
|
Thread.sleep(30000L);
|
||||||
|
logger.info("onEvent:send:atWork:waitron");
|
||||||
|
return events.atWork().send(MessageBuilder.withPayload("waitron").build());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.info("onEvent:skip:test");
|
logger.info("onEvent:skip:test");
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
spring.application.name=waitron
|
spring.application.name=waitron
|
||||||
|
|
||||||
logging.level.root=info
|
logging.level.root=info
|
||||||
|
logging.level.io.spring=debug
|
||||||
|
logging.level.org.springframework.cloud=debug
|
||||||
|
logging.level.com.rabbitmq.client=debug
|
||||||
Reference in New Issue
Block a user