嗨,你在 mule 中输入 Https 出站端点,但总是收到异常,说消息有效负载的类型是 byte[]
信息 2014-12-31 12:55:02,699 [[collectFlow].connector.VM.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.VM.mule.default.dispatcher.12905544'.对象是:VMMessageDispatcher信息 2014-12-31 12:55:02,699 [[collectFlow].ScatterGatherWorkManager.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'IPS-HTTPS-TwoWaySSL-Connector.dispatcher.14325410'.对象是:HttpsClientMessageDispatcher错误 2014-12-31 12:55:04,961 [[collectFlow].collectFlow.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
消息:
发现路由 0 的异常。消息有效负载的类型为:字节[]
代码 : MULE_ERROR--2
异常堆栈为:1. 发现路由异常:0。消息有效负载的类型为:byte[] (org.mule.routing.CompositeRoutingException) org.mule.routing.CollectAllAggregationStrategy:51 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/routing/CompositeRoutingException.html)
<scatter-gather doc:name="Scatter-Gather">
<processor-chain>
<logger message="Just before calling https" level="INFO" doc:name="Logger"/>
<set-property propertyName="Content-Type" value="text/xml" doc:name="Property"/>
<https:outbound-endpoint exchange-pattern="request-response" host:"localhost" port:"8080" path="test" method="POST" connector-ref="IPS-HTTPS-TwoWaySSL-Connector" tracking:enable-default-events="true" doc:name="HTTPS" encoding="UTF-8" mimeType="text/xml" contentType="text/xml"/>
</processor-chain>
<vm:outbound-endpoint exchange-pattern="one-way"
doc:name="Logger In Queue" path="FlowIn"/>
</scatter-gather>
问题是聚合策略。由于您没有定义任何自定义策略,因此 Mule 使用默认策略(默认聚合器 CollectAllAggregationStrategy 不处理 byte[] 有效负载)
如果您不需要来自分散消息的任何信息,只需实施虚拟聚合器策略来创建骡子事件:
流:
<scatter-gather doc:name="Scatter-Gather">
<custom-aggregation-strategy class="org.myproject.DummyAggregationStrategy" />
<processor-chain>
<logger message="Just before calling https" level="INFO" doc:name="Logger"/>
<set-property propertyName="Content-Type" value="text/xml" doc:name="Property"/>
<https:outbound-endpoint exchange-pattern="request-response" host:"localhost" port:"8080" path="test" method="POST" connector-ref="IPS-HTTPS-TwoWaySSL-Connector" tracking:enable-default-events="true" doc:name="HTTPS" encoding="UTF-8" mimeType="text/xml" contentType="text/xml"/>
</processor-chain>
<vm:outbound-endpoint exchange-pattern="one-way"
doc:name="Logger In Queue" path="FlowIn"/>
</scatter-gather>
策略类:
public class DummyAggregationStrategy implements AggregationStrategy {
@Override
public MuleEvent aggregate(AggregationContext context) throws MuleException {
if(context.collectEventsWithoutExceptions().isEmpty())
return new DefaultMuleMessage();
else
return DefaultMuleEvent.copy(context.collectEventsWithoutExceptions().get(0));
}
}
有关详细信息,请查看分散-收集文档。