如何在Mulesoft中设置睡眠流程而不会丢失消息负载 [英] How to set sleep into the flow in Mulesoft without losing the message payload

查看:154
本文介绍了如何在Mulesoft中设置睡眠流程而不会丢失消息负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想插入脚本来延迟Mulesoft中的处理流程。我试图在groovy中插入脚本,但是我丢失了消息有效负载,所以当我必须获取消息有效载荷时收到空指针。
如何才能不丢失邮件的有效载荷?



谢谢 解决方案

如果您在流程中使用 Groovy 组件,则可以如下定义sleep(): - $ / $>

 < scripting:component doc:name =Groovy> 
< scripting:script engine =Groovy><![CDATA [
sleep(10000);
return message.payload;]]>
< / scripting:script>
< / scripting:component>

记住 返回在 Groovy message.payload,以便您可以在最后获得有效内容,否则您将获得 null 有效内容



Groovy 存在一个丢失负载的问题,如果您没有在最后返回,那么在 Groovy 中,您需要结束时返回有效负载,这就是您接收 null 有效负载的原因



或者,您可以使用表达式组件如下: -

 < expression-component> 
Thread.sleep(10000);
< / expression-component>


I'd like insert script to delay processing flow in Mulesoft. I have tried to insert script in groovy but I lost the messagge payload, so when I have to get message payload recived null pointer. How can I to do not lose the message payload?

Thanks

解决方案

If you are using Groovy component in you flow,then you can define sleep() as follow :-

<scripting:component doc:name="Groovy">
  <scripting:script engine="Groovy"><![CDATA[
    sleep(10000);
    return message.payload;]]>
  </scripting:script>
</scripting:component>

And remember to return message.payload in Groovy so that you can get the payload at the end or else you will get null payload

Groovy has an issue of loosing payload if you don't return at the end, so, in Groovy you need to return the payload at end, and that's the reason you are receiving null payload

Alternately you can use expression-component as follow:-

<expression-component>
    Thread.sleep(10000);
</expression-component>

这篇关于如何在Mulesoft中设置睡眠流程而不会丢失消息负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆