1
votes

I am working on the below case study.

  1. Create a Rest Service to accept Reference id.
  2. Use the Reference Id to get data (CLOB) from Database.
  3. Put the data(CLOB) in a channel(queue) for further processing.
  4. Reply to the rest client with response data in JSON format {"status": true,"message": "RECEIVED"}

I have the Rest Service created and using the Ref Id am getting the data from database but I am unable to send the response back to the rest client after putting the message in a channel(queue). The output received by Rest Client is : No reply received within timeout

Basically I want the request thread to be returned immediately after the data (CLOB) is pushed to the channel(queue).

Below is the configuration.

<int:channel id="responseChannel"/>
<int:channel id="initCalculation">
   <int:queue/>
</int:channel>


<!-- GET -->
<int-http:inbound-gateway 
    request-channel="httpGetChannel"
    reply-channel="responseChannel"
    supported-methods="GET"
    path="/init/{refId}"
    payload-expression="#pathVariables.refId">

    <int-http:request-mapping  produces="application/json"/>

</int-http:inbound-gateway>


<int:chain input-channel="httpGetChannel" output-channel="initCalculation">
    <int-jdbc:stored-proc-outbound-gateway
            id="outbound-gateway-storedproc-get-forma" data-source="dataSource"
            is-function="false"
            stored-procedure-name="XX_EMPROC.GET_FRMA"
            ignore-column-meta-data="true"
            expect-single-result="true">

        <int-jdbc:sql-parameter-definition name="V_REF_ID" direction="IN" />
        <int-jdbc:sql-parameter-definition name="V_FRMA"   direction="OUT" type="#{T(oracle.jdbc.OracleTypes).CLOB}"/>

        <int-jdbc:parameter name="V_REF_ID" expression="payload" />
    </int-jdbc:stored-proc-outbound-gateway>

    <!- Convert to JSON Format -->
    <int:service-activator ref="brInitGateway" method="getResponse"/>

</int:chain>


<int:outbound-channel-adapter channel="initCalculation"  ref="brInitGateway"   method="process"/>

Kindly advise on the corrections needed in the above.

Thanks

1

1 Answers

2
votes

Look, there is no body who sends message as a reply to the <int-http:inbound-gateway>. You have declared responseChannel, but who is going to use it as an output-channel?

I'd suggest you to do this:

<publish-subscribe-channel id="responseChannel"/>

<int:chain input-channel="httpGetChannel" output-channel="responseChannel">


 <int:bridge input-channel="responseChannel" output-channel="initCalculation"/>

So, what happens here:

The publish-subscribe-channel for the reply-channel makes an internal bridge to the replyChannel header as one of the subscribers.

You send a result from the <chain> to that channel. Therefore the <int-http:inbound-gateway> gets its reply.

Having that <int:bridge> from response to the initCalculation you have a second subscriber and, therefore, send a message to the required queue.

If you are not interested in the brInitGateway.getResponse() as a reply for the HTTP request, you should consider do not have that reply-channel="responseChannel" at all, but still use some <publish-subscribe-channel> to send to the queue and some transformer to prepare a reply, e.g.:

<transformer input-channel="prepareProcess" expression="' {"status": true,"message": "RECEIVED"}'"/>

This transformer is without output-channel because it is going to send its result into the replyChannel header, therefore to the <int-http:inbound-gateway> initiator.