如何从 java dsl 访问默认幂等存储库映射? [英] How to access Default Idempotent Repository map from java dsl?

查看:25
本文介绍了如何从 java dsl 访问默认幂等存储库映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Apache Camel 的新手.如何在 Java DSL 中访问 Camel 默认幂等存储库映射.

I am newbie to Apache Camel. How can i access Camel Default Idempotent Repository map in Java DSL.

路线:

from("file://C:/folderA?noop=true")
.to("file://C:/folderB")
.end();

当我在路由中说 noop=true 时,幂等将是真的.现在我需要在 java dsl 中获取幂等映射.请告诉我如何访问它?

When i say noop=true in route, then idempotent will be true. Now i need to get Idempotent map in java dsl. Please tell me how to access this?

提前致谢.

推荐答案

如果你想访问底层映射,你应该指定你自己的 idempotentRepository bean.使用现有的 MemoryIdempotentRepository 应该很容易.

If you want to access the underlying map, you should specify your own idempotentRepository bean. Using the existing MemoryIdempotentRepository should be pretty easy.

//Instantiate repository and get map
IdempotentRepository<String> repo = MemoryIdempotentRepository.memoryIdempotentRepository()
Map<String, Object> map = repo.getCache();

//Bind the repo to the Camel Context Registry using the id "repo"
//This changes depending upon how you are running Camel

//In your RouteBuilder...
from("file://C:/folderA?noop=true&idempotentRepository=#repo")
  .to("file://C:/folderB")
  .end();

这篇关于如何从 java dsl 访问默认幂等存储库映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆