I have a REST service that returns a json simple {message: "ok"}. When I use Respond Mediator this stop further processing of a message and send the message back to the client.
I need to send response to client, and then execute task asynchronously, but if I use it ignores the next call to a sequence or an endpoint.
How can you respond synchronously (response to client) and then invoke a service, without response mediator ignore the next mediator?
thanks;
I was able to solve the challenge. effectively Clone mediator not just clone message, it give new separate life to new message.
<api xmlns="http://ws.apache.org/ns/synapse" name="porticApiAsyn" context="/test">
<resource methods="POST" url-mapping="/asyn">
<inSequence>
<log>
<property name="message" value="asyn"/>
</log>
<payloadFactory media-type="json">
<format>{"message":"asyn test"}</format>
<args/>
</payloadFactory>
<clone continueParent="true" sequential="true">
<target sequence="logSequence"/>
</clone>
<respond/>
</inSequence>
In this case, the message is sent to logsequence, then the response mediator is executed. Thanks for your help.
For your case you could even do the following
<api xmlns="http://ws.apache.org/ns/synapse" name="porticApiAsyn" context="/test">
<resource methods="POST" url-mapping="/asyn">
<inSequence>
<log>
<property name="message" value="asyn"/>
</log>
<payloadFactory media-type="json">
<format>{"message":"asyn test"}</format>
<args/>
</payloadFactory>
<clone continueParent="true" sequential="true">
<target sequence="logSequence"/>
<target>
<sequence>
<respond/>
</sequence>
</target>
</clone>
</inSequence>
I guess it should work as well and is maybe more readable
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.