admin管理员组

文章数量:1394099

I have two routes in Apache Camel where parent route is calling child route with enrich component. enrich doesnt share Unit of Work (Exchange) by default, but I need that because of sharing variables in ExchangeVariableRepository. So I try to use setting shareUnitOfWork for that. But variable is not shared and exchange Id for parent and child route is different.

Here is my code:

    from("direct:importCsv")
        .log("importCsv: Exchange: ${exchangeId}")
        .enrich()
          .constant("direct:GetHeadOfficeIdStep")
          .shareUnitOfWork()

    from("direct:GetHeadOfficeIdStep")
        .log("GetHeadOfficeIdStep: Exchange: ${exchangeId}")

This produce these logs:

2025-03-12 06:45:49,496 INFO  [...] (vert.x-worker-thread-13) importCsv: Exchange: 8E006DC89BB640F-0000000000000000
2025-03-12 06:45:49,497 INFO  [...] (vert.x-worker-thread-13) GetHeadOfficeIdStep: Exchange: 8E006DC89BB640F-0000000000000001

Exchange Id is different for parent and child route ...

本文标签: shareUnitOfWork of Apache Camel enrich component doesnt workStack Overflow