2015-02-08 133 views
0

有时(非常频繁),ESB禁止某些SOAP请求。我如何阻止骡子这样做?我不知道阻塞的原因是什么。禁止Mule ESB阻止一些请求

这是多么我已经配置HTTP侦听器在骡子的配置:

<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是一个简单的序列化的类(同JavaFX.Pair) 注:输入是一个XML SOAP

- 编辑 - 这是骡子配置文件:

<?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> 

回答

1

假设createInputStreamWithStringKeyInstance(你没有描述,所以它真的很难帮你)返回InputStream,骡结束了建立一个JMS StreamMessage(每this call)。

从骡子代码,你可以看到它水渠流的有效载荷送入这个逻辑StreamMessage

while ((len = value.read(buffer)) != -1) 
{ 
    streamMessage.writeBytes(buffer, 0, len); 
} 

这是很好的,提供由createInputStreamWithStringKeyInstance返回的流不会做后面的任何特殊业务现场。

另请注意,JMS StreamMessage可能不是您想要的。你读过its Javadoc吗?它说:

StreamMessage对象用于发送Java编程语言中的原语类型流。

我很确定你想用JMS BytesMessage。如果有效负载是byte[](根据上述链接转换逻辑),Mule会创建此类消息,因此您宁愿在jms:outbound-endpoint之前有<object-to-byte-array-transformer/>

+0

谢谢。我编辑了我的问题。我做了你所说的,并在之前放置了。这使得原始数据包的内容类型过于宽松。 (服务提供者机器抱怨:SOAP消息传递需要HTTP内容类型标头,并且没有被发现 – MoienGK 2015-02-09 06:09:53

+0

您的流程中没有任何内容会创建适当的SOAP响应:您打算作为SOAP XML响应返回什么?是的,您需要设置正确的响应头文件,这是偶然的工作 – 2015-02-09 18:03:06

+0

请求是一个肥皂消息,我将它转换为字节数组然后做一些东西(不改变它的内容),然后传递精确的请求作为一个outbound.that是你的肥皂xml – MoienGK 2015-02-09 18:31:11