Mule ESB选择流控制路径 [英] Mule ESB choice flow control route

查看:106
本文介绍了Mule ESB选择流控制路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在M子中,我有以下流程: 有一个选择流控件,它可以测试输入并验证输入String是否等于'ctr1'.

In Mule I have the following flow : there is a choice flow control which test the input and verify if the input String equals 'ctr1'.

    <flow name="mediationFlow1" doc:name="mediationFlow1">
         <file:inbound-endpoint path="C:\MuleStudio\SandBox\input" pollingFrequency="3000" responseTimeout="10000" doc:name="File"/>
        <file:file-to-string-transformer doc:name="File to String"/>
        <choice doc:name="Choice">
            <when expression="payload=='ctr1'">
                <cxf:jaxws-client operation="find" serviceClass="services.port.PortWS" port="portWSPort" enableMuleSoapHeaders="true" doc:name="Port"/>
                <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8080/Actors/portWS" doc:name="portWS"/>
            </when>
            <otherwise >
                <cxf:jaxws-client operation="find" serviceClass="services.douane.DouaneWS" port="douaneWSPort" enableMuleSoapHeaders="true" doc:name="Douane"/>
                <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8080/Actors/douaneWS" doc:name="douaneWS"/>
            </otherwise>
        </choice>
       <file:outbound-endpoint path="C:\MuleStudio\SandBox\output" outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].xml " responseTimeout="10000" doc:name="Outgoing File"/>
    </flow>
</mule>

当我正确运行它们时,两个Web服务调用都可以正常工作,但是当我添加选择ccontrol时,这就是我得到的:

the both web services call works perfectly when I run them speratly, but when I add the choice ccontrol this is what I got :

INFO  2013-05-14 15:48:07,892 [[mediation].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\MuleStudio\SandBox\input\input.txt
INFO  2013-05-14 15:48:08,206 [[mediation].mediationFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
INFO  2013-05-14 15:48:08,216 [[mediation].mediationFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
INFO  2013-05-14 15:48:08,253 [[mediation].mediationFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
INFO  2013-05-14 15:48:08,254 [[mediation].mediationFlow1.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.http.mule.default.dispatcher.7073225'. Object is: HttpClientMessageDispatcher
INFO  2013-05-14 15:48:08,260 [[mediation].mediationFlow1.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.http.mule.default.dispatcher.7073225'. Object is: HttpClientMessageDispatcher
INFO  2013-05-14 15:48:09,035 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.dispatcher.23051110'. Object is: FileMessageDispatcher
INFO  2013-05-14 15:48:09,035 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.dispatcher.23051110'. Object is: FileMessageDispatcher
INFO  2013-05-14 15:48:09,040 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\MuleStudio\SandBox\output\14-05-13_1368539289037.xml
INFO  2013-05-14 15:48:09,043 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.module.xml.transformer.jaxb.JAXBContextResolver: No common Object of type 'class javax.xml.bind.JAXBContext' configured, creating a local one for: SimpleDataType{type=services.port.Port, mimeType='text/xml'}, SimpleDataType{type=java.io.InputStream, mimeType='*/*'}
ERROR 2013-05-14 15:48:09,058 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : An invalid return type "class java.io.InputStream" was specified for transformer "JAXBMarshallerTransformer"
Code                  : MULE_ERROR-266
--------------------------------------------------------------------------------
Exception stack is:
1. An invalid return type "class java.io.InputStream" was specified for transformer "JAXBMarshallerTransformer" (org.mule.api.transformer.TransformerException)
  org.mule.module.xml.transformer.jaxb.JAXBMarshallerTransformer:122 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.transformer.TransformerException: An invalid return type "class java.io.InputStream" was specified for transformer "JAXBMarshallerTransformer"
    at org.mule.module.xml.transformer.jaxb.JAXBMarshallerTransformer.doTransform(JAXBMarshallerTransformer.java:122)
    at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:411)
    at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:362)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

我不确定它是否来自选择测试表达式? 虽然我找不到很多有关如何使用选择控制流的详细信息.

I'm not sure if it's comming from the choice test expression ? Altough I cant find much informations on how to use the choice control flow in details.

感谢您的帮助. 谢谢.

appreciate your help. thank you.

推荐答案

默认情况下,M子在流中应用大量转换器,以将有效负载转换为所需格式.

Mule by default applies lot of transformers in the flow to convert the payload to required formats.

在没有选择路由器的情况下,它将返回的对象转换为xml字符串以写入文件. 但是使用选择路由器,程序员有责任提供一个转换器,将响应对象转换为XML字符串.

In the case when there is no choice router it converts the object returned into an xml string to write to file. But with choice router it is the programmers responsibility to provide a transformer to convert the response object to an XML string.

在选择路由器之后并在写入文件出站之前,将以下mule-xml jaxb对象添加到xml转换器.

Add the following mule-xml jaxb object to xml transformer after choice router and before writing to file-outbound.

 .....
    </otherwise>
 </choice>

 <xm:jaxb-object-to-xml-transformer name="ObjectToXML" jaxbContext-ref="MyJaxb"  returnClass="java.lang.String" encoding="UTF-8"/>

希望这会有所帮助.

这篇关于Mule ESB选择流控制路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆