使用JPA Consumer,转换和其他中间路由操作来处理Camel ETL路由的示例。这包括针对另一个JPA实体的额外pollEnrich步骤。 pollEnrich步骤应该基于定义的带有动态参数的namedQuery来消耗实体数据(通过先前交换的#params注册表映射传递)。它完全忽略了namedQuery。它也忽略了任何内联查询 - 无论查询多么简单 - 只需将初始记录轮询到maximumResults。
from("jpa:com.tcfbank.example.entity.PersonEntity?maxMessagesPerPoll=500&persistenceUnit=cedb&consumer.namedQuery=withOccupationCodeAndValidIdentification&consumer.initialDelay=3000&delay=3000&consumeDelete=false&consumeLockEntity=false")
.convertBodyTo(CanonicalPerson.class)
.to("bean:parameterManager")
.pollEnrich("jpa:com.tcfbank.example.entity.AccountEntity?persistenceUnit=cedb2&consumer.resultClass=com.tcfbank.example.entity.AccountEntity&consumer.namedQuery=byCustomerId&consumer.parameters=#params&consumeDelete=false&consumeLockEntity=false&maximumResults=50", 5000, "accountAggregationStrategy").id("EnrichWithAccounts")
.to("bean:scoringClient")
.setHeader(Exchange.FILE_NAME, el("${in.body.customerId}.xml"))
.to("file:target/customers");
答案 0 :(得分:-1)
pollEnrich不是jpaconsumer而是pollingconsumer,请从参数中删除前缀使用者
.pollEnrich("jpa:com.tcfbank.example.entity.AccountEntity?persistenceUnit=cedb2&<strike>consumer.</strike>resultClass=com.tcfbank.example.entity.AccountEntity&<strike>consumer.</strike>namedQuery=byCustomerId&<strike>consumer.</strike>parameters=#params&consumeDelete=false&consumeLockEntity=false&maximumResults=50", 5000, "accountAggregationStrategy").id("EnrichWithAccounts")