有时(非常频繁)mule ESB阻止了一些SOAP请求。我怎么能阻止Mule这样做呢?我不知道阻塞的原因是什么。
这就是我在mule config中配置http-listener的方式:
<http:listener-config name="HTTP_listener" host="${MachineName}" port="${InboundPort}" doc:name="HTTP listener Configuration" />
<flow name="etryFlow" >
<http:listener allowedMethods="POST" config-ref="HTTP_listener" path="/{name}" doc:name="HTTP"/>
<set-payload value="#[app.registry.pairFactory.createInputStreamWithStringKeyInstance(message.inboundProperties['http.uri.params']['name'],payload))]" />
<jms:outbound-endpoint connector-ref="jms-connector" ref="UnsortedOrders" />
<logger level="INFO" doc:name="Logger" message="****Entry****" />
</flow>
注意:被禁止的请求将转换为BlockingTransferInputStream而不是BufferInputStream。
谢谢。**编辑**
这是createInputStreamWithStringKeyInstance实现:
public static Pair<String, byte[]> createByteArrayWithStringKeyInstance(String key, byte value[]) throws IOException {
return new Pair<String, byte[]>(key, value);
}
和Pair.java是一个简单的Serializable类(与JavaFX.Pair相同) 注意:输入是SOAP XML
- 编辑 - 这是mule配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:bpm="http://www.mulesoft.org/schema/mule/bpm"
xmlns:client="http://www.mulesoft.org/schema/mule/client"
xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:management="http://www.mulesoft.org/schema/mule/management"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/3.2/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.2/mule-jms.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/bpm http://www.mulesoft.org/schema/mule/bpm/3.2/mule-bpm.xsd
http://www.mulesoft.org/schema/mule/client http://www.mulesoft.org/schema/mule/client/3.2/mule-client.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/management http://www.mulesoft.org/schema/mule/management/current/mule-management.xsd ">
<jms:activemq-connector name="jms-connector" brokerURL="${BrokerURL}" disableTemporaryReplyToDestinations="true" specification="1.1"/>
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="UnsortedOrders" queue="UnsortedOrders"/>
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="DestinationEMC" queue="DestinationEMC" />
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="DestinationOriginal" queue="DestinationOriginal"/>
<management:jmx-default-config>
<management:credentials>
<spring:entry key="admin" value="admin"/>
</management:credentials>
</management:jmx-default-config>
<spring:beans>
<context:property-placeholder location="classpath:Application.properties"/>
<spring:bean name="NoFactsBean" class="java.util.ArrayList" scope="singleton"/>
<spring:bean id="objectStore" class="org.mule.util.store.QueuePersistenceObjectStore"/>
<spring:bean id ="requestBean" class="com.hamgam.hit.esb.bean.RequestBean" factory-method="getInstance" scope="singleton"/>
</spring:beans>
<message-properties-transformer name="contentTypeTextXML">
<add-message-property key="Content-Type" value="text/xml;charset=UTF-8;" />
</message-properties-transformer>
<http:listener-config name="HTTP_listener" host="${MachineName}" port="${InboundPort}" doc:name="HTTP listener Configuration" />
<flow name="etryFlow">
<http:listener allowedMethods="POST" parseRequest="false" config-ref="HTTP_listener" path="/{name}" doc:name="HTTP" />
<object-to-byte-array-transformer/>
<expression-component>
payload = app.registry.requestBean.createServiceRequest(message.inboundProperties['http.uri.params']['name'],payload);
</expression-component>
<jms:outbound-endpoint connector-ref="jms-connector" ref="UnsortedOrders" />
<logger level="INFO" doc:name="Logger" message="****#[payload] Enters Entry****" />
</flow>
<flow name="consumeRequestsFlow" >
<jms:inbound-endpoint ref="UnsortedOrders" connector-ref="jms-connector" />
<logger level="INFO" doc:name="Logger" message="**** #[payload] Enters consumeRequestsFlow ****" />
<choice doc:name="Choice">
<when expression="#[app.registry.requestBean.isEMCRequired(payload)]">
<jms:outbound-endpoint connector-ref="jms-connector" ref="DestinationEMC" />
</when>
<otherwise>
<jms:outbound-endpoint connector-ref="jms-connector" ref="DestinationOriginal" />
</otherwise>
</choice>
</flow>
<flow name="ConsumeEmcQ">
<jms:inbound-endpoint connector-ref="jms-connector" ref="DestinationEMC" />
<logger level="INFO" doc:name="Logger" message="**** #[payload] Enters ConsumeEmcQ ****" />
<set-payload value="#[app.registry.requestBean.sendToEMC(payload)]" />
<until-successful objectStore-ref="objectStore" maxRetries="${MaximumRetry}" secondsBetweenRetries="${RetryInterval}">
<http:outbound-endpoint address="${ECMURL}" exchange-pattern="one-way">
<transformer ref="contentTypeTextXML"/>
</http:outbound-endpoint>
</until-successful>
</flow>
<flow name="ConsumeOrigQ">
<jms:inbound-endpoint connector-ref="jms-connector" ref="DestinationOriginal" />
<logger level="INFO" doc:name="Logger" message="**** #[payload] Enters ConsumeOriginalQ ****" />
<set-payload value="#[app.registry.requestBean.sendToDestination(payload)]" />
</flow>
<flow name = "EMCResponseFlow" >
<http:inbound-endpoint host="${MachineName}" port="${EMCResponsePort}" exchange-pattern="one-way">
<set-property propertyName="SOAPAction" value="#[message.inboundProperties['SOAPAction']]"/>
<transformer ref="contentTypeTextXML"/>
</http:inbound-endpoint>
<logger level="INFO" doc:name="Logger" message="***EMCResponseEntry****" />
</flow>
</mule>
答案 0 :(得分:1)
假设createInputStreamWithStringKeyInstance
(您没有描述,所以它很难帮助您)返回InputStream
,Mule最终会构建一个JMS StreamMessage
(按this call)。
从Mule代码中,您可以看到它使用以下逻辑将流式有效负载排放到StreamMessage
:
while ((len = value.read(buffer)) != -1)
{
streamMessage.writeBytes(buffer, 0, len);
}
这很好,只要createInputStreamWithStringKeyInstance
返回的流不会在场景后做任何花哨的业务。
另请注意,JMS StreamMessage
可能不是您想要的。你看过its Javadoc了吗?它说:
StreamMessage对象用于以Java编程语言发送基元类型流。
我很确定你想要使用JMS BytesMessage。如果有效负载是byte[]
(根据上述链接的转换逻辑),Mule会创建此类消息,因此您需要在<object-to-byte-array-transformer/>
之前设置jms:outbound-endpoint
。