Apache Camel 中的选项与查询参数

Options vs Query Parameters in Apache Camel

Apache camel 组件页面在选项和查询参数下有字段,但没有明确的参数路径位置,从示例中我能够确定它们与选项一致。 我想知道选项和查询参数之间的区别。

Apache Camel的应用在启动时,会在Camel Context中注册路由,一旦context启动,from()和to()中的组件就不能修改,例如:

String param = "a = xxxx & y = bbb";
...
to ("http4: //api.xxx.yy?" + stop)
...

它只会在启动时被评估,所以即使参数变量中的字符串的值发生变化,路由将始终使用 a=xxxx&y=bbb 作为默认值,因为它已经在上下文中被初始化骆驼(你可以看到骆驼在应用程序启动期间在日志中记录路由)。

这些选项不仅可以在结构上进行更改,具体取决于所讨论组件的设计,而且还可以通过使用 application.ymlapplication.properties 或通过 java 如下例所示:

application.properties

camel.component.http.http-configuration=br.com.pack.impl.MyHttpConfiguration

在java

HttpConfiguration config = new HttpConfiguration();
config.setProxyAuthMethod("Digest");
config.setProxyAuthUsername("myUser");
config.setProxyAuthPassword("myPassword");

HttpComponent http = context.getComponent("http", HttpComponent.class);
http.setHttpConfiguration(config);

from("direct:start")
  .to("http4://www.google.com/search");

我希望它有助于澄清一点

选项用于配置组件,在创建端点时使用查询参数。