java - Mule ESB - 在同一流程中配置多个组件

标签 java spring mule esb

我在尝试将 Spring 组件添加到 Mule Flow 时收到错误消息。这应该是一个常见的用户案例,但我无法找到正确的文档或示例。提前致谢。

以下是原始配置并且工作正常:

<flow name="ApplicationEndpoint">
    <inbound-endpoint address="server:port/JSONAPI/"/>
    <jersey:resources>
        <component>
            <spring-object bean="myJerseyService"/>     
        </component>            
    </jersey:resources>

    <catch-exception-strategy doc:name="Catch Exception Strategy">
        <flow-ref name="ErrorHandling" doc:name="Flow Reference"/>
    </catch-exception-strategy>         
</flow>

我只是想添加一个新组件来进行一些后处理。当我尝试这个时,它不起作用:

<flow name="ApplicationEndpoint">
    <inbound-endpoint address="server:port/JSONAPI/"/>
    <jersey:resources>
        <component>
            <spring-object bean="myJerseyService"/>     
        </component>            
    </jersey:resources>
    <component>
      <spring-object bean="postProcessor"/>
    <component>
    <catch-exception-strategy doc:name="Catch Exception Strategy">
        <flow-ref name="ErrorHandling" doc:name="Flow Reference"/>
    </catch-exception-strategy>         
</flow>

“postProcessor”在配置中的其他位置映射为 spring bean。

我收到的错误消息是:

org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:发现以元素“组件”开头的无效内容。需要 '{"http://www.mulesoft.org/schema/mule/core ":abstract-lifecycle-adapter-factory, "http://www.mulesoft.org/schema/mule/core ":binding}' 之一。

最佳答案

上面的错误清楚地表明标签 <component>没有关闭..

例如,它应该采用以下格式:-

 <component>
    <spring-object bean="postProcessor"/>
 </component>

您需要像下面这样结束标签:- </component>

还有一件事......我尝试运行你的代码,但由于 server:port/JSONAPI/在您的 inbound-endpoint 中配置地址它给出一个错误,指出 xml 格式错误

所以我修改了您的代码如下,它运行成功:-

<flow name="ApplicationEndpoint">
    <inbound-endpoint address="http://localhost:8189/JSONAPI"/>
    <jersey:resources>
        <component>
            <spring-object bean="myJerseyService"/>     
        </component>            
    </jersey:resources>
    <component>
      <spring-object bean="postProcessor"/>
    </component>
    <catch-exception-strategy doc:name="Catch Exception Strategy">
        <flow-ref name="ErrorHandling" doc:name="Flow Reference"/>
    </catch-exception-strategy>         
</flow>

所以,您现在可以使用它并根据您的要求进行修改

关于java - Mule ESB - 在同一流程中配置多个组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30384697/

相关文章:

java - 表单提交发送不需要的 GET 请求

java - 一起使用 Spring Boot、QueryDSL 和 Springfox Swagger - Guava 版本不匹配

java - 使用 Mule ESB 的 LDAP 连接器在搜索时获得一致的响应

java - 映射缩减框架

java - 在 Eclipse 中通过 RSE 插件运行远程 Java 程序时遇到问题

java - 如何向所有登录用户发送通知

java - 在mule3中,如何为choice-when路由器设置自定义表达式?

Mavenized Mule 项目但 Munit 测试运行失败

Java数组列表大小问题

java - 为什么 Gson 会漂亮地打印到控制台,而不是文件?