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

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

问题描述

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

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时,幂等将为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天全站免登陆