[英]Mule ESB - Configure Multiple Components in same Flow
I am getting an error message when trying to add a Spring component to a Mule Flow. 尝试将Spring组件添加到Mule Flow时收到错误消息。 This should be a common user-case, but I wasn't able to find the right documentation or examples. 这应该是一个常见的用户案例,但是我找不到正确的文档或示例。 Thanks in advance. 提前致谢。
The follow was the original configuration and works fine: 以下是原始配置,效果很好:
<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>
I simply want to add a new component to do some post-processing. 我只是想添加一个新组件来进行一些后处理。 When I try this, it doesn't work: 当我尝试此操作时,它不起作用:
<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>
Where "postProcessor" maps elsewhere in the config as a spring bean. 其中“ postProcessor”将配置中的其他位置映射为spring bean。
The error message I get is: 我收到的错误消息是:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'component'. org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:发现无效的内容(从元素“ component”开始)。 One of '{" http://www.mulesoft.org/schema/mule/core ":abstract-lifecycle-adapter-factory, " http://www.mulesoft.org/schema/mule/core ":binding}' is expected. '{“ http://www.mulesoft.org/schema/mule/core”:abstract-lifecycle-adapter-factory “,” http://www.mulesoft.org/schema/mule/core“:binding }之一' 是期待。
The above error clearly shows that the tag <component>
is not closed.. 上面的错误清楚地表明标记<component>
没有关闭。
for example, it should be in following format :- 例如,应采用以下格式:-
<component>
<spring-object bean="postProcessor"/>
</component>
where you need to end the tag like the following :- </component>
您需要在代码末尾添加如下代码:- </component>
One more thing ... I tried to run your code, but due to server:port/JSONAPI/
configured in your inbound-endpoint
address it gives a error saying the xml is malformed 还有一件事...我尝试运行您的代码,但是由于在您的inbound-endpoint
地址中配置了server:port/JSONAPI/
,因此出现错误,表明xml格式错误
So I modified your code as following and it ran successfully :- 所以我修改了您的代码,如下所示,它成功运行了:
<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>
So, you can now use it and modify as per your requirement 因此,您现在可以使用它并根据需要进行修改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.