1
votes

currently I am working with Mule and need to do something like this:

-- FLOW UPDATED --

Flow

Where the http endpoint is request-response (not one way). I mean, I would like to query the request on my http in RequestFlow and get the response from the http in ServiceResponse.

How to do so? Thanks for your help.

-- XML Configuration ADDED -- (Request-Reply Tag Updated)

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.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/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd">
    <custom-transformer name="StringToNameString" class="de.fraport.sources.StringtoAusweis" doc:name="Java"/>
    <wmq:connector name="WMQ" hostName="localhost" port="1414" queueManager="localmanager" validateConnections="true" doc:name="WMQ" ccsId="819"/>
    <data-mapper:config name="json_to_xml" transformationGraphPath="json_to_xml.grf" doc:name="json_to_xml"/>

    <flow name="RequestFlow" doc:name="RequestFlow">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="uebermittleAusweisdaten" doc:name="HTTP"/>
        <expression-filter expression="#[message.payload !='/favicon.ico']" doc:name="Expression"/>
        <set-variable variableName="id" value="#[message.id]" doc:name="Variable"/>
        <data-mapper:transform config-ref="json_to_xml" doc:name="JSON To XML">
            <data-mapper:input-arguments>
                <data-mapper:input-argument key="id">#[flowVars['id']]</data-mapper:input-argument>
            </data-mapper:input-arguments>
        </data-mapper:transform>
        <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="D:\Workspace\soaptest\mobako.sender.xsl" doc:name="XSLT" encoding="ISO8859-1"/>
        <mulexml:dom-to-xml-transformer  doc:name="DOM to XML" outputEncoding="ISO8859-1"/>
        <wmq:outbound-endpoint queue="LSMH.ZKSEAP.SERVICEBUS" connector-ref="WMQ" doc:name="ZKSEAP IN" encoding="ISO8859-1" />
        <request-reply storePrefix="mainFlow">
        <wmq:outbound-endpoint queue="LSMH.ZKSEAP.SERVICEBUS" connector-ref="WMQ" doc:name="ZKSEAP IN" encoding="ISO8859-1" correlationId="#[message.id]"/>
        <wmq:inbound-endpoint queue="ZKSEAP.LSMH.SERVICEBUS" connector-ref="WMQ" doc:name="ZKSEAP OUT" encoding="UTF-8"/>
    </request-reply>
        <http:response-builder doc:name="HTTP Response Builder"/>
    </flow>
    <flow name="ServiceResponse" doc:name="ServiceResponse">
        <wmq:inbound-endpoint queue="ZKSEAP.LSMH.SERVICEBUS" connector-ref="WMQ" doc:name="ZKSEAP OUT" encoding="UTF-8"/>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
    </flow>
</mule>

-- Error Update --

After I changed the flow and use reply-response routing message, i try to debug the flow. And I found something weird. When the debugger reach the

request-reply

component, it will automatically goes back to

expression

component (looping). How can I solve it?

1

1 Answers

2
votes

To achieve your goal, you need to:

  • Make the HTTP endpoint in RequestFlow a request-response one,
  • Use a request-reply routing message processor to perform the asynchronous operations over WMQ while blocking RequestFlow until a response comes from ZKSEAP OUT.