如何在 Camel 3.4.2 的 CamelContext 中添加自定义 MDCUnitOfWork

How to add a custom MDCUnitOfWork in CamelContext in Camel 3.4.2

如何在 Camel 3.4.2 的 CamelContext 中添加自定义 MDCUnitOfWork。早些时候我可以添加 using camelContext.setUnitOfWorkFactory(..) 但现在,我没有看到该方法。谢谢

CamelContext 接口在 Apache Camel 3.x 中得到了简化,仅提供与最终用户最相关的方法。您可以使用 CamelContext#adapt.

访问所有高级方法

参见Apache Camel 3 migration guide

The APIs on CamelContext has been reduced a bit to focus on relevant API for Camel end users. The advanced use-cases and for SPI and component developers, then some of the APIs from CamelContext has been moved to ExtendedCamelContext which you can access via adapt.

您可以在 CustomUnitOfWorkFactoryTest

中找到示例
context.adapt(ExtendedCamelContext.class).setUnitOfWorkFactory(new MyUnitOfWorkFactory());