Mule ESB 如何实现一个计数器变量来计算一个流被调用的次数 [英] Mule ESB How to implement a counter variable to count how much times a flow is called
本文介绍了Mule ESB 如何实现一个计数器变量来计算一个流被调用的次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在讨论如何实现一个计数器,该计数器在调用流程时会增加 1 步.例如:我有一个名为:http://localhost:8080/doSomething 和一个变量计数器的流.当我在 doSomething 服务中按 Enter 时,计数器变量将增加 1
I am wordering about how to implement a counter which is will increase 1 step when flow is called. For example: I have a flow named: http://localhost:8080/doSomething and a variable counter. The counter variable will increase by 1 when I hit enter in doSomething service
非常感谢
推荐答案
在流程开始时在 mule 应用注册表中初始化一个整数值为 1 的变量,如下所示:
Initialize a variable with integer value 1 in mule app registry in the starting of your flow as below:
<expression-component doc:name="Expression"><![CDATA[#[app.registry.put('counter',1)]]]></expression-component>
增加值使用:
<expression-component doc:name="Expression"><![CDATA[#[app.registry.put('counter',app.registry['counter']+1)]]]></expression-component>
要检索计数器标志的最终值,请使用以下表达式:
To retrieve final value of the counter flag, use the expression:
#[app.registry.get('counter')]
这篇关于Mule ESB 如何实现一个计数器变量来计算一个流被调用的次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文