2
votes

I have a flow where I receive request via webservice. I forward that request to a JMS queue using component binding. However, I would like to get async-reply from that queue and use it as response to the webservice. Do I need to use reply-to and async-reply-router in the flow? Or is there any other way to do that in Mule 3? Any pointers?

<flow name="mviService">
    <http:inbound-endpoint address="http://localhost:62005/mvi"
        exchange-pattern="request-response">
        <cxf:jaxws-service serviceClass="com.xyz.services.mvi.MVIServicePortType" />
    </http:inbound-endpoint>
    <component class="com.pennmutual.services.mvi.MVIServiceImpl">
        <binding interface="com.pennmutual.mvi.helper.XMLReqProcessorInterface"
            method="process121Order">
            <jms:outbound-endpoint queue="mviq.121.order" />
        </binding>
            </component>

            <async-reply>

            </async-reply>

      </flow>

============ EDITED - SEE BELOW FOR RE-FRAMED QUESTION =================

I think I haven't done a good job in describing the scenario. Let me try again. Here's the scenario --

  1. A client calls our service described in this flow "mviService". mviService gets XML request via HTTP/SOAP based inbound endpoint. Let's call this request as XML121Request.4
  2. A component defined in MVI "com.xyz.services.mvi.MVIServiceImpl" makes some changes in XML121Request.
  3. Forwards this XML121 to a JMS queue "mviq.121.order". It uses component binding for this.
  4. The outbound endpoint to this JMS queue is a third party web service where this request is forwarded. The third party acknowledges the receipt of XML121 and the synchronous web service call returns.
  5. The response from that third party service comes at a later point of time, which is generally couple of seconds. The response comes asynchronously. Third party invokes another webservice endpoint on MVI and sends the XML121Response.
  6. MVI puts this response in a JMS queue named "mviq.async.service.reply".
  7. The "mviService" flow needs to wait for this response and send this response (after some modification) to caller(in step 1).

I'm able to get the response from third party and this response is enqued in a queue named "mviq.async.service.reply". I would like to use/consume this message and return it as a response to first call to MVI.

I'm trying to use "request-reply".

    <request-reply timeout="60000">
        <vm:outbound-endpoint path="request" />
        <jms:inbound-endpoint queue="mviq.async.service.reply"
            exchange-pattern="one-way" />
    </request-reply>

THe problem is that even though I don't want to have outbound-endpoint in this case, I still have to put one as this is required by request-reply tag. The flow waits for 60 seconds at that point of time but even if I put something in the queue "mviq.async.service.reply" the correlation ID doesn't match so the service timesout and returns an error.

flow is mentioned below.

<flow name="mviService">
    <http:inbound-endpoint address="http://localhost:62005/mvi"
        exchange-pattern="request-response">
        <cxf:jaxws-service serviceClass="com.xyz.services.mvi.MVIServicePortType" />
    </http:inbound-endpoint>
    <component class="com.pennmutual.services.mvi.MVIServiceImpl">
        <binding interface="com.xyz.mvi.helper.XMLReqProcessorInterface"
            method="process121Order">
            <jms:outbound-endpoint queue="mviq.121.order" />
        </binding>
    </component>

    <!-- <logger message="XML Correlation ID 1 is #[mule:message.headers(all)]" /> -->
    <request-reply timeout="60000">
        <vm:outbound-endpoint path="request" /> <!-- we don't care about this -->
        <jms:inbound-endpoint queue="mviq.async.service.reply"
            exchange-pattern="one-way" />
    </request-reply>
        <!-- <component class="com.xyz.mvi.CreateMVIServiceResponse"/> -->
</flow>

===== FLow with REPLY TO =============

<flow name="mviService">
    <http:inbound-endpoint address="http://localhost:62005/mvi"
        exchange-pattern="request-response">
        <cxf:jaxws-service serviceClass="com.xyz.services.mvi.MVIServicePortType" />
    </http:inbound-endpoint>
    <component class="com.xyz.services.mvi.MVIServiceImpl">
        <binding interface="com.xyz.mvi.helper.XMLReqProcessorInterface"
            method="process121Order">
            <jms:outbound-endpoint queue="mviq.121.order" exchange-pattern="request-response">
                <message-properties-transformer scope="outbound">
                    <add-message-property key="MULE_REPLYTO" value="mviq.async.service.reply" />
                </message-properties-transformer>
            </jms:outbound-endpoint>
        </binding>
     </component>
</flow>
1
What if you specify request-response as the exchange-pattern of the jms:outbound-endpoint? Don't you get a synchronous response that way?David Dossot
The problem is that the flow has to be one-way. The reason being that jms:outbound-endpoint flow invokes a web service and the response from that webservice comes asynchronously at a later point of time (in few seconds) through another JMS queue named "mviq.async.service.reply". I would like to listen to this jms queue "mviq.async.service.reply" in the above mentioned flow "mviService".user1493140
What if you set a JMSReplyTo outbound property to mviq.async.service.reply prior to the jms:outbound-endpoint (configured to be request-response). Alternatively, set a MULE_REPLYTO outbound property to jms://mviq.async.service.reply.David Dossot
David, I tried to re-frame the question. I'll appreciate if you can give me some feedback based on that.user1493140
You can't use request-reply for your scenario. Have you tried my above suggestion?David Dossot

1 Answers

2
votes

I'd like to suggest you do not create a service component class and instead use cxf:proxy-service, which will give you direct access to the SOAP envelope and the opportunity to assemble the response the way you want at XML level.

This will free you from the constraint a service component class imposes on you, hence waive the need to use bindings and open the door to using request-response.

See this SO answer and check the (skinny) proxy service user guide for more information.