How to move to out sequence from in sequence in WSO2 ESB

I faced a situation, where I need to send a custom response after the request is being sent to the message queue. I couldn’t use FORCE_SC_ACCEPT property as I need to send a response. In such a case we can use loopback mediator which switch from in sequence to out sequence and in side the out sequence payload factory mediator can be used to construct the custom response.

Simple skeleton as follows,

<store messageStore="JMSMessageStore"/>
<payloadFactory media-type="json">