I'm trying to figure out why does my spring boot application stop, given the code:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@Configuration
@EnableIntegration
public class FirestoreCommandIntegrationFlow {
@Bean
public StandardIntegrationFlow registerInboundAdapter() {
return IntegrationFlows.from("input")
.transform("hello"::equals)
.handle(m -> System.err.println("work"))
.get();
}
}
What im trying to figure out is why does the application just stop without any errors, it starts normal and then after few seconds it just drops the subscription to the "input" channel and closes the flow. I know this is probably a silly question but i just can't find a reason why does the application stop. I've been folowing the https://github.com/spring-projects/spring-integration-java-dsl/wiki/Spring-Integration-Java-DSL-Reference and as i understood it, my flow should keep on listening to the "input" channel and the flow should keep running.
NOTE: My springboot app has web server disabled with spring.main.web-environment=false
in application.properties
Log:
2019-01-09 13:32:21.261 INFO 12658 --- [ main] c.r.t.m.Application : Starting Application on ...
2019-01-09 13:32:21.265 INFO 12658 --- [ main] c.r.t.m.Application : No active profile set, falling back to default profiles: default
2019-01-09 13:32:21.348 INFO 12658 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@625732: startup date [Wed Jan 09 13:32:21 CET 2019]; root of context hierarchy
2019-01-09 13:32:21.744 INFO 12658 --- [ main] o.s.i.c.IntegrationRegistrar : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2019-01-09 13:32:22.025 INFO 12658 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2019-01-09 13:32:22.030 INFO 12658 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
2019-01-09 13:32:22.199 INFO 12658 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration$$EnhancerBySpringCGLIB$$b59005e8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-01-09 13:32:22.446 INFO 12658 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2019-01-09 13:32:22.854 INFO 12658 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-01-09 13:32:22.863 INFO 12658 --- [ main] o.s.c.s.DefaultLifecycleProcessor : Starting beans in phase 0
2019-01-09 13:32:22.863 INFO 12658 --- [ main] o.s.i.e.EventDrivenConsumer : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2019-01-09 13:32:22.863 INFO 12658 --- [ main] o.s.i.c.PublishSubscribeChannel : Channel 'application.errorChannel' has 1 subscriber(s).
2019-01-09 13:32:22.864 INFO 12658 --- [ main] o.s.i.e.EventDrivenConsumer : started _org.springframework.integration.errorLogger
2019-01-09 13:32:22.864 INFO 12658 --- [ main] o.s.i.e.EventDrivenConsumer : Adding {transformer} as a subscriber to the 'input' channel
2019-01-09 13:32:22.864 INFO 12658 --- [ main] o.s.i.c.DirectChannel : Channel 'application.input' has 1 subscriber(s).
2019-01-09 13:32:22.864 INFO 12658 --- [ main] o.s.i.e.EventDrivenConsumer : started org.springframework.integration.config.ConsumerEndpointFactoryBean#0
2019-01-09 13:32:22.872 INFO 12658 --- [ main] c.r.t.m.Application : Started Application in 2.032 seconds (JVM running for 2.652)
2019-01-09 13:32:22.874 INFO 12658 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@625732: startup date [Wed Jan 09 13:32:21 CET 2019]; root of context hierarchy
2019-01-09 13:32:22.876 INFO 12658 --- [ Thread-2] o.s.c.s.DefaultLifecycleProcessor : Stopping beans in phase 0
2019-01-09 13:32:22.877 INFO 12658 --- [ Thread-2] o.s.i.e.EventDrivenConsumer : Removing {transformer} as a subscriber to the 'input' channel
2019-01-09 13:32:22.877 INFO 12658 --- [ Thread-2] o.s.i.c.DirectChannel : Channel 'application.input' has 0 subscriber(s).
2019-01-09 13:32:22.877 INFO 12658 --- [ Thread-2] o.s.i.e.EventDrivenConsumer : stopped org.springframework.integration.config.ConsumerEndpointFactoryBean#0
2019-01-09 13:32:22.877 INFO 12658 --- [ Thread-2] o.s.i.e.EventDrivenConsumer : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2019-01-09 13:32:22.877 INFO 12658 --- [ Thread-2] o.s.i.c.PublishSubscribeChannel : Channel 'application.errorChannel' has 0 subscriber(s).
2019-01-09 13:32:22.877 INFO 12658 --- [ Thread-2] o.s.i.e.EventDrivenConsumer : stopped _org.springframework.integration.errorLogger
2019-01-09 13:32:22.878 INFO 12658 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2019-01-09 13:32:22.878 INFO 12658 --- [ Thread-2] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
Process finished with exit code 0
Your flow does nothing; it is static, and does nothing on its own; it has no dynamic components (pollers, message-driven adapters); it needs something to send data to it, on a thread; e.g. the main thread, or some other non-daemon thread.
e.g.
@Bean
public ApplicationRunner runner(MessageChannel input) {
return args -> {
while (true) {
input.send(someMessage);
Thread.sleep(1_000);
}
}
}
This will run on the main thread after starting.