我有一个Mule流,POJO作为当前消息有效负载。我想通过调用返回text/plain
的HTTP REST服务来丰富消息。我尝试了几种不同的方法,但每次都会出错。我目前的流程如下:
<foreach doc:name="For Each">
<enricher source="#[message.payload]"
target="#[variable:agentCode]" doc:name="Message Enricher">
<http:outbound-endpoint exchange-pattern="request-response" host="localhost"
port="8080"
path="ods.service/agent/agentCode/#[message.payload.getAgentEntityNumber()]"
method="GET" mimeType="text/plain" doc:name="HTTP"/>
</enricher>
<component class="za.co.sci.mule.agt.MoveVariablesToPayload"
doc:name="Move variables to message"/>
</foreach>
richr之后的组件只是将变量值移动到我的POJO中。当我执行此操作时,我得到:
An invalid return type "interface org.mule.api.MuleMessage"
was specified for transformer "JAXBMarshallerTransformer"
这对我来说没什么意义,但我试过关掉运输变压器,我得到了:
java.lang.ClassCastException: org.mule.transport.http.ReleasingInputStream
cannot be cast to java.lang.Integer
哪种有意义,但并没有真正帮助。
我的问题是,是否可以通过调用简单的text/plain
REST服务来丰富消息?如果是这样,我该如何构建我的richher?
更新
根据以下建议进行更改并仍然相同。完整堆栈跟踪:
ERROR 2013-10-11 16:01:03,998 [[sci_silica_interface].connector.http.mule.default.receiver.02] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : An invalid return type "interface org.mule.api.MuleMessage" was specified for transformer "JAXBMarshallerTransformer"
Code : MULE_ERROR-266
--------------------------------------------------------------------------------
Exception stack is:
1. An invalid return type "interface org.mule.api.MuleMessage" 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 "interface org.mule.api.MuleMessage" 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.transformer.AbstractTransformer.transform(AbstractTransformer.java:363)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
org.mule.api.transport.DispatchException: Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://localhost:8080/ods.service/agent/agentCode/12345, connector=HttpConnector
答案 0 :(得分:0)
如果要将<http:outbound-endpoint />
的结果存储到变量中,首先需要使用该流。
要做到这一点,你只需要这样做就可以了解你的内容:
<processor-chain>
http:outbound-endpoint exchange-pattern="request-response" host="localhost"
port="8080"
path="ods.service/agent/agentCode/#[message.payload.getAgentEntityNumber()]"
method="GET" mimeType="text/plain" doc:name="HTTP"/>
<object-to-string-transformer />
</processor-chain>
答案 1 :(得分:0)
我最终放弃了尝试使用HTTP端点。相反,我编写了一个自定义Java类,它执行REST调用和丰富(它实现Callable
)。我使用<component>
标记将其包含在流程中。我仍然相信有更多正确的方式,但无法找到任何示例,这种方式有效。