Spring Cloud 数据流的准备情况
Spring Cloud Data Flow的文档描述了如何与Kubernetes准备探针集成。我正在本地开发我的数据流,并在Docker-Compose配置中运行,而我们等待K8S SCDF环境站立。
是否有其他方法可以实现准备就绪 /不发送SCDF的数据上下文?组件旋转后,我需要重新调用,然后对结果进行一些计算。尝试失败的事情:
- 使用ApplicationavailabilityEvents-在发布加载 +汇编后,发布fargeinessstate。当Spring完成自己的负载时,它会发布Accepting_traffic,因此不会在我的服务中等待我。
- 设置一个应用程序设备,该应用程序还可以作为定制事件的应用程序列表,我在计算完成后投掷的应用程序列表。有效地,Run()方法看起来像:
public class ApplicationStartupRunner implements ApplicationRunner, ApplicationListener {
private boolean sessionLoaded = false;
public void run(ApplicationArguments args) {
doTimeExpensiveThing();
while (!sessionLoaded) {
TimeUnit.MILLISECONDS.sleep(150);
}
}
public void onApplicationEvent(SessionLoadEvent event) {
this.sessionLoaded = true;
}
}
附加技术注意:Spring Boot应用程序是作为处理器构建的,该应用程序使用函数作为Bean提供的功能来提供其功能,ALA 公共功能< flux< changeEvent>,flux< arter ProcessChangeEvents()()
最佳,无论我使用的是在Docker-Compose中起作用的方法,我都会将其连接到一个指示器中,该指标将由K8S及其就绪探针拾取。鉴于SCDF可以部署在K8,Docker-Compose(本地)或CloudFoundry上,希望我可以挂在我刚刚忽略的模型中。
Spring Cloud Data Flow's documentation describes how to integrate with kubernetes Readiness probes. I'm developing my dataflow locally and running it in a docker-compose configuration, while we wait for our k8s SCDF environment to be stood up.
Is there another way to implement a readiness / do not send data context for SCDF? Upon component spin-up, I need to make a RESTful call and then run some computations on the results. Things attempted unsuccessfully:
- use of ApplicationAvailabilityEvents - publishing a ReadinessState.ACCEPTING_TRAFFIC after the load + compilation is complete, after publishing a ReadinessState.REFUSING_TRAFFIC. When Spring completes its own load, it publishes an ACCEPTING_TRAFFIC, and so doesn't wait for mine from my service.
- setting up an ApplicationRunner which also serves as an ApplicationListener for custom events which I throw when the computations are complete. Effectively, the run() method looks like:
public class ApplicationStartupRunner implements ApplicationRunner, ApplicationListener {
private boolean sessionLoaded = false;
public void run(ApplicationArguments args) {
doTimeExpensiveThing();
while (!sessionLoaded) {
TimeUnit.MILLISECONDS.sleep(150);
}
}
public void onApplicationEvent(SessionLoadEvent event) {
this.sessionLoaded = true;
}
}
Additional technical note: the Spring Boot application is built as a processor, which is using a function exposed as a Bean to provide its capability, alapublic Function<Flux<ChangeEvent>, Flux<Alert>> processChangeEvents()
Optimally, whatever approach I use which works in docker-compose, I'll wire into an indicator which'll be picked up by k8s and its readiness probe. Given that SCDF can be deployed on k8s, docker-compose (locally), or CloudFoundry, hoping that there's a model I can hook into that I've just overlooked.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
潜在的答案:与其使用ApplicationRunner,不如在ProcessChangeEvents方法中等待,不要返回该功能,直到启动处理完成为止。
在我们的情况下,由于Dotime Expensivething是一种异步活动,因此我使用观看/等待Session LoadSload的标志的技术,但现在在ProcessChangeEvents方法本身中。
对其他方法非常开放。这看起来像是在起作用,尽管不确定我还没有遇到过的陷阱。
Potential answer: instead of using the ApplicationRunner, wait in the processChangeEvents method and do not return the function until startup processing is complete.
In our case, because the doTimeExpensiveThing is an asynchronous activity, I use the technique of watching/waiting for the sessionLoaded flag, but now within the processChangeEvents method itself.
Very open to guidance on other approaches. This appears like it's working, though not sure there aren't gotchas I haven't caught yet.