简体   繁体   English

如何避免在WSO2 EI中使用响应调解器忽略下一个调解器?

[英]How to avoid ignore the next mediator using response mediator in WSO2 EI?

I have a REST service that returns a json simple {message: "ok"}. 我有一个REST服务,它返回一个简单的json {message:“ ok”}。 When I use Respond Mediator this stop further processing of a message and send the message back to the client. 当我使用Respond Mediator时,这将停止对消息的进一步处理,并将消息发送回客户端。

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 我想它应该也可以工作,并且可读性更好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM