读取包含键值对的文件的内容,无需正常解析

2022-01-19 00:00:00 java apache-camel mule fuseesb jbossfuse

我的方案是从文件端点读取文件,该文件仅包含键值 paris,如属性文件,并根据键从中获取一些数据.

My scenario is to read a file from a file endpoint which contains only key value paris like a property file and take a few data from it based on the key .

知道如何使用自定义 bean 或 java 组件来完成它们.

Any idea how to do them other that using a custom bean or java component.

我想知道这在 Mule 或 Camel 中是否可行.

I would like to know if this is possible any way in Mule or Camel.

提前致谢.

推荐答案

如果你想使用 Camel 路由来获取文件,那么像这样

If you want to use a Camel route, to pickup files, then something like this

from("file:inbox")
   .convertBodyTo(Properties.class)
   .log("The foo value is {${body[foo]}")
   .log("The bar value is {${body[bar]}")

然后我们需要一个来自 java.io.File -> java.util.Properties 的类型转换器.我们可以直接将其添加到 camel-core 中.

What we then need is a type converter from java.io.File -> java.util.Properties. Which we could add to camel-core out of the box.

我记录了一张在 Camel 中添加该类型转换器的票:https://issues.apache.org/jira/browse/CAMEL-7312

I logged a ticket to add that type converter out of the box in Camel: https://issues.apache.org/jira/browse/CAMEL-7312

相关文章