Spring Boot Integration 流程应用程序在启动时关闭
SpringBoot Integration flow application closing on start
我想弄清楚为什么我的 spring 引导应用程序停止,给定代码:
@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();
}
}
我想弄清楚的是,为什么应用程序没有任何错误就停止了,它正常启动,然后几秒钟后它就放弃了对 "input" 频道的订阅并关闭了流程。
我知道这可能是一个愚蠢的问题,但我就是找不到应用程序停止的原因。我一直在关注 https://github.com/spring-projects/spring-integration-java-dsl/wiki/Spring-Integration-Java-DSL-Reference,据我了解,我的流量应该继续收听 "input" 频道,流量应该保持 运行.
注意:我的 spring 启动应用程序在 application.properties
中使用 spring.main.web-environment=false
禁用了网络服务器
日志:
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
如果您的应用程序不是 Web 应用程序,但仍想继续定期收听/运行。尝试添加注释
@EnableScheduling
或
@Scheduled
到您的主应用程序或一些示例任务 运行ner
@EnableScheduling(initialDelay = 100, fixedRate = 100)public void run(){System.out.println("debug print time -->" + Calendar.getInstance().getTime());}
这也可以应用于 SpringApplication 上下文。
你的流程什么都不做;它是静态的,它自己什么也不做;它没有动态组件(轮询器、消息驱动的适配器);它需要在线程上向它发送数据;例如主线程,或其他一些非守护线程。
例如
@Bean
public ApplicationRunner runner(MessageChannel input) {
return args -> {
while (true) {
input.send(someMessage);
Thread.sleep(1_000);
}
}
}
这将在启动后 运行 在主线程上。
我想弄清楚为什么我的 spring 引导应用程序停止,给定代码:
@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();
}
}
我想弄清楚的是,为什么应用程序没有任何错误就停止了,它正常启动,然后几秒钟后它就放弃了对 "input" 频道的订阅并关闭了流程。 我知道这可能是一个愚蠢的问题,但我就是找不到应用程序停止的原因。我一直在关注 https://github.com/spring-projects/spring-integration-java-dsl/wiki/Spring-Integration-Java-DSL-Reference,据我了解,我的流量应该继续收听 "input" 频道,流量应该保持 运行.
注意:我的 spring 启动应用程序在 application.properties
中使用spring.main.web-environment=false
禁用了网络服务器
日志:
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
如果您的应用程序不是 Web 应用程序,但仍想继续定期收听/运行。尝试添加注释
@EnableScheduling
或
@Scheduled
到您的主应用程序或一些示例任务 运行ner
@EnableScheduling(initialDelay = 100, fixedRate = 100)public void run(){System.out.println("debug print time -->" + Calendar.getInstance().getTime());}
这也可以应用于 SpringApplication 上下文。
你的流程什么都不做;它是静态的,它自己什么也不做;它没有动态组件(轮询器、消息驱动的适配器);它需要在线程上向它发送数据;例如主线程,或其他一些非守护线程。
例如
@Bean
public ApplicationRunner runner(MessageChannel input) {
return args -> {
while (true) {
input.send(someMessage);
Thread.sleep(1_000);
}
}
}
这将在启动后 运行 在主线程上。