diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java index dd7160ca0..ba615535d 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java @@ -36,6 +36,8 @@ import org.springframework.cloud.stream.reflection.GenericsUtils; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource; @@ -273,6 +275,16 @@ public class DefaultBinderFactory if (useApplicationContextAsParent) { springApplicationBuilder.parent(this.context); } + else { + springApplicationBuilder.listeners(new ApplicationListener() { + @Override + public void onApplicationEvent(ApplicationEvent event) { + if (context != null) { + context.publishEvent(event); + } + } + }); + } // If the current application context is not set as parent and the environment // is set, // provide the current context as an additional bean in the BeanFactory.