搜索

95.4. Functions

download PDF

Camel 添加以下 XPath 函数,可用于访问交换:

功能参数类型描述

in:body

none

对象

仅返回消息正文。

in:header

标头名称

对象

将返回消息正文。

out:body

none

对象

弃用 将返回 OUT 消息正文。

out:header

标头名称

对象

弃用 将返回 OUT 消息标头。

function:properties

属性的键

字符串

使用 a .

function:simple

简单表达式

对象

来评估一个语言。

注意

当返回类型是 NodeSet 时,不支持 function:propertiesfunction:simple,比如与 Split EIP 搭配使用时。

下面是一个示例,其中显示了一些正在使用的功能。

95.4.1. 功能示例

如果要在 Spring XML 文件中配置路由,您可以使用 XPath 表达式,如下所示

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"
                xmlns:foo="http://example.com/person">
    <route>
      <from uri="activemq:MyQueue"/>
      <filter>
        <xpath>/foo:person[@name='James']</xpath>
        <to uri="mqseries:SomeOtherQueue"/>
      </filter>
    </route>
  </camelContext>
</beans>

请注意,我们如何在 XPath 表达式中重复使用命名空间前缀 foo,以便更轻松地使用基于命名空间的 XPath 表达式。

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.