我在 Spring Boot 1.5.8 应用程序中使用 Camel 2.19.2。例如,如果我想让我的几条路线“状态感知”,我该如何实现呢?我所说的“状态感知”是指路由将启动,通知组件工作流已经开始,然后它将执行特定于路由的逻辑,完成后,它将通知组件工作流已完成。如果可能的话,我希望这自动发生,并且不必在我想使用此功能的每个路由构建器中调用特定逻辑。
这是一个代码示例,就像我的意思:
public class FooRouteBuilder extends StatusAwareRouteBuilder {
@Override
public void configure() {
// Here I want to have this route know how to notify something
// that this processing has begun, but I do not want to have
// to explicitly call a processor to make it happen, but it
// should know what to do by virtue of extending a custom
// route builder, if appropriate, or by some other/better
// mechanism
// Now conduct any route-specific logic
from("vm:myAction")
.process("myProcessor");
// Now handle the status notification that this is finished...
// Here I want to have this route know how to notify something
// that this processing has finished
}
}
从概念上讲,这几乎就像 AOP,所以我希望能够在一个地方定义此行为并将其包含在需要使用此行为的一些路由中。有没有办法可以做到这一点?我看到有用于测试的adviceWith,但我需要这个用于常规操作。提前致谢。