Reputation: 35
I'm working with wso2 ESB 4.8.1
My complete functionality is:
Step one: I make a call to a service that respond me with a processId (Asynchcronous)
The service make the work asociated to that processId
Step two: I have to iterate calling the service with the processId Until a response that indicate me that process has finished and return me the result
I'm having problems with step two implementation.
Upvotes: 1
Views: 1258
Reputation: 35
Thanks you very much I'll try your solution.
I have make some advances with a secuence that check if the processId has finished and if not the secuence call it own (recursion), I'm testing this alternative, I put the code (some thinks are hardcode but the important is the idea)
<resource methods="GET" uri-template="/test2">
<inSequence>
<log>
<property name="***** IN" value="Estoy en el GET /recursivetest1/test2"></property>
</log>
<call>
<endpoint name="uploadServlet">
<!-- this is the request that return the processId -->
<http method="get" uri-template="http://localhost:1234/ProyectoWebMultipartForm/UploadServlet?fase=escaneo"></http>
</endpoint>
</call>
<log>
<property name="data_id" expression="json-eval($.data_id)"></property>
</log>
<property name="escaneo" expression="json-eval($.data_id)"></property>
<sequence key="iterate_calls2"></sequence>
<send></send>
</inSequence>
<outSequence>
</outSequence>
</resource>
</api>
/////////////////
<sequence xmlns="http://ws.apache.org/ns/synapse" name="iterate_calls2" trace="disable">
<call>
<!-- this is the request that check if the processId has finished-->
<endpoint name="uploadServlet">
<http method="get" uri-template="http://localhost:1234/ProyectoWebMultipartForm/UploadServlet?fase=chequeo"></http>
</endpoint>
</call>
<property xmlns:ns="http://org.apache.synapse/xsd" name="resultado" expression="json-eval($.scan_results.scan_all_result_a)"></property>
<filter xmlns:ns="http://org.apache.synapse/xsd" source="get-property('resultado')" regex="Clean">
<then>
<log level="full">
<property name="MESSAGE" value="No hay virus"></property>
</log>
</then>
<else>
<property name="mensaje" expression="json-eval($.mensaje)"></property>
<filter source="get-property('mensaje')" regex="Escaneo sin finalizar">
<then>
<!-- the processId has not finished, I call again to the sequence, recursion-->
<log level="full">
<property name="MESSAGE" value="El escaneo no ha finalizado antes del sleep"></property>
</log>
<script language="js">
<![CDATA[java.lang.Thread.sleep(200);]]></script>
<log level="full">
<property name="MESSAGE" value="El escaneo no ha finalizado despues del sleep"></property>
</log>
<sequence key="iterate_calls2"></sequence>
</then>
<else>
<!-- the processId has finished, I have end-->
<log level="full">
<property name="MESSAGE" value="No hay virus"></property>
</log>
</else>
</filter>
</else>
</filter>
</sequence>
Upvotes: 1
Reputation: 5946
You can store the response with the process id into a Message Store.
You define a Message Processor (a scheduled message forwarding processor) that consume messages from this store and send them into a proxy service (defined inside the same ESB)
In this proxy service :
Upvotes: 1