请求 - 回复路由器无法正常工作

时间:2014-01-09 17:28:12

标签: mule

我对骡子中的请求 - 回复路由器的问题感到困惑。我正在使用mule版本3.4.0。请求 - 回复用于fork-join模式,我在博客网站http://blogs.mulesoft.org/aggregation-with-mule-fork-and-join-pattern/上关注了这篇文章。

    <request-reply>
      <all enableCorrelation="ALWAYS">
        <vm:outbound-endpoint path="PathA"/>
        <vm:outbound-endpoint path="PathB"/>
      </all>
      <vm:inbound-endpoint path="FinalResponse">
         <message-properties-transformer>
              <add-message-property key="MULE_CORRELATION_GROUP_SIZE" value="2" />
         </message-properties-transformer>
         <collection-aggregator />
      </vm:inbound-endpoint>
    </request-reply>

我面临的问题是在未达到请求 - 回复后放置的处理器。在mule中,我看到2个响应已发送到FinalResponse vm端点。我尝试使用自己的自定义聚合器代替集合聚合器。但这还没有实现。我不知道如何调试这个问题。请注意,我有两个这样的请求 - 回复路由器在两个流程中。有人可以帮忙吗。

添加mule配置。对于abbrevity仅附加父流和子流之一

ParentFlow

    <flow name="ParentFlow" doc:name="ParentFlow" tracking:enable-default-events="true">
    <file:inbound-endpoint path="${SourceFilePath}"
        connector-ref="ParentFlowInboundConnector" 
        responseTimeout="10000" tracking:enable-default-events="true">
        <file:filename-regex-filter pattern="${REGEX}" caseSensitive="false"/>

    </file:inbound-endpoint>

    <object-to-string-transformer doc:name="Object to String"/>
    <message-properties-transformer
        doc:name="Message Properties">
        <add-message-property key="Source_System" value="XXX" />
        <add-message-property key="publisherName" value="YYY" />
        <add-message-property key="FlowName" value="ZZZ"/>
    </message-properties-transformer>
    <!-- This would store the message in the db -->
    <wire-tap>
        <vm:outbound-endpoint path="PERSITENCE.OUT"/>
    </wire-tap>

    <request-reply>
            <all doc:name="Move the message to all endpoints" enableCorrelation="ALWAYS">
                <vm:outbound-endpoint path="PathA"/>
                <vm:outbound-endpoint path="PathB"/>
                <vm:outbound-endpoint path="PathC"/>
                <vm:outbound-endpoint path="PathD"/>
            </all>
        <vm:inbound-endpoint path="Response">               
            <message-properties-transformer>                    
                <add-message-property key="MULE_CORRELATION_GROUP_SIZE" value="4" />                
            </message-properties-transformer>               
            <collection-aggregator failOnTimeout="false" doc:name="Collection Aggregator" />
        </vm:inbound-endpoint>

    </request-reply>
    <component class="ProcessorA"  />
    <component class="ProcessorB" />
    <exception-strategy ref="Exception Strategy" doc:name="Reference Exception Strategy"/>
</flow>

子流

<flow name="PathA" doc:name="PathA">
    <vm:inbound-endpoint path="PathA" >
        <vm:transaction action="ALWAYS_BEGIN"/>
    </vm:inbound-endpoint>
    <message-properties-transformer doc:name="Message Properties">                  
        <add-message-property key="originalFilename_processing" value="#[message.inboundProperties.originalFilename]" />                
    </message-properties-transformer>
    <message-properties-transformer doc:name="Message Properties">                  
        <add-message-property key="directory" value="#[message.inboundProperties.directory]" />             
    </message-properties-transformer>

    <message-properties-transformer doc:name="Message Properties">
        <add-message-property key="Destination_System" value="XXX" />
    </message-properties-transformer>

    <file:outbound-endpoint path="${OutPathA}" connector-ref="FileConnector_1" 
        tracking:enable-default-events="true"/>

    <!--Send email alerts -->
     <all doc:name="All" >
        <processor-chain>
            <message-property-filter pattern="turnOffEmail=false" caseSensitive="true" doc:name="Message Property"/>
            <custom-transformer class="com.XXX.YYY.ZZZ.VelocityTemplateResolver" doc:name="Java">
                <spring:property name="flowName" value="PPPP"/>
            </custom-transformer>
            <smtp:outbound-endpoint host="${SMTP_HOSTNAME}" port="${SMTP_PORT}" user="${SMTP_USERNAME}" password="${SMTP_PASSWORD}" to="${TO_ADDRESS}" from="${FROM_ADDRESS}" subject="${MAIL_SUBJECT}" cc="${MAIL_CC_ADDRESS}" bcc="${MAIL_BCC_ADDRESS}" responseTimeout="10000" transformer-refs="emailVelocityMessageTransformer"  tracking:enable-default-events="true"/>
        </processor-chain>
        <processor-chain>
            <message-property-filter pattern="turnOffEmail=false" caseSensitive="true" doc:name="Message Property"/>
            <custom-transformer class="com.XXX.YYY.ZZZ.VelocityTemplateResolver" doc:name="Java">
                <spring:property name="flowName" value="FlowName"/>
            </custom-transformer>
            <smtp:outbound-endpoint host="${SMTP_HOSTNAME}" port="${SMTP_PORT}" user="${SMTP_USERNAME}" password="${SMTP_PASSWORD}" to="${MAIL_TO_ADDRESS}" from="${MAIL_FROM_ADDRESS}" subject="${MAIL_SUBJECT}" cc="${MAIL_CC_ADDRESS}" bcc="${BCC_ADDRESS}" responseTimeout="10000" transformer-refs="emailVelocityMessageTransformer" tracking:enable-default-events="true"/>
        </processor-chain>
        <processor-chain>
            <message-property-filter pattern="turnOffEmail=false" caseSensitive="true" doc:name="Message Property"/>
            <custom-transformer class="com.XXX.YYY.ZZZ.VelocityTemplateResolver" doc:name="Java">
                <spring:property name="flowName" value="AAAA"/>
            </custom-transformer>
            <smtp:outbound-endpoint host="${SMTP_HOSTNAME}" port="${SMTP_PORT}" user="${SMTP_USERNAME}" password="${SMTP_PASSWORD}" to="${MAIL_TO_ADDRESS}" from="${MAIL_FROM_ADDRESS}" subject="${MAIL_SUBJECT}" cc="${MAIL_CC_ADDRESS}" bcc="${MAIL_BCC_ADDRESS}" responseTimeout="10000" transformer-refs="emailVelocityMessageTransformer" tracking:enable-default-events="true"/>
        </processor-chain>
    </all>
    <rollback-exception-strategy doc:name="Rollback Exception Strategy" maxRedeliveryAttempts="${MAX_REDELIVERY_ATTEMPTS}" enableNotifications="false">
        <logger message="==Rollback log ===" level="INFO" doc:name="Logger"/>
    </rollback-exception-strategy>
</flow>

1 个答案:

答案 0 :(得分:0)

问题的最可能原因是相关ID

您可能希望检查发送到路径A和路径B的消息的相关ID。在FinalResponse VM入站端点上收到的消息需要具有相同的相关ID,否则将不接受作为响应以前发送的消息。换句话说,请求 - 回复不会接受入站端点中的任何内容,而只接受与出站端点上发布的相关ID与请求 - 回复路由器匹配的消息。

您可以使用此选项设置自定义相关ID -

<set-property propertyName="MULE_CORRELATION_ID" value="some-correlation-id" />