mule2.2.x架构(六)示例学习scripting
所有的示例文档
http://www.mulesoft.org/display/MULE2INTRO/Examples
本示例参考地址
http://www.mulesoft.org/display/MULE2INTRO/Scripting+Example
6.1 标准输入调用script处理业务打印到标准输出
主要配置文件change-machine.xml。。。。为啥叫这个名字呐。
<description>
JSR-223 script as the service component.
</description>
<context:property-placeholder location="scripting/default-config.properties"/>
<configuration defaultSynchronousEndpoints="true"/>
<stdio:connector name="SystemStreamConnector"
promptMessage="How much more change do you need? (enter an amount such as 2.37)"
messageDelayTime="1000"/>
<custom-transformer name="StringToNumber" class="com.sillycat.easymule.scripting.transformer.StringToNumber"/>
<custom-transformer name="DollarsToCents" class="com.sillycat.easymule.scripting.transformer.SimpleMathTransformer">
<spring:property name="operation" value="multiply"/>
<spring:property name="factor" value="100"/>
</custom-transformer>
<model name="main">
<service name="Accumulator">
<inbound>
<!-- 标准输入 -->
<stdio:inbound-endpoint system="IN"
transformer-refs="StringToNumber DollarsToCents"/>
<!-- 队列输入 -->
<vm:inbound-endpoint path="input" transformer-refs="DollarsToCents"/>
</inbound>
<component>
<!-- 计算处理 -->
<singleton-object class="com.sillycat.easymule.scripting.service.AccumulatorComponent"/>
</component>
<outbound>
<chaining-router>
<!-- 队列输出到queen -->
<vm:outbound-endpoint path="script"/>
<!-- 标准输出 -->
<stdio:outbound-endpoint system="OUT"/>
</chaining-router>
</outbound>
</service>
<service name="ScriptService">
<inbound>
<!-- 队列输入到queen -->
<vm:inbound-endpoint path="script"/>
</inbound>
<script:component>
<script:script file="${scriptfile}">
<property key="currency" value="${currency}"/>
</script:script>
</script:component>
</service>
</model>
其实properties中两种配置都应该可以的,python和groovy的脚本都支持的
#These properties can be passed in via the command line i.e. -Dcurrency=GBP
#scriptfile=scripting/greedy.groovy
#currency=USD
scriptfile=scripting/greedy.py
currency=GBP
当然pom.xml上要将null/lib/user/里面的jar都加上。
另外应当注意这个
<chaining-router>
<!-- 队列输出到queen -->
<vm:outbound-endpoint path="script"/>
<!-- 标准输出 -->
<stdio:outbound-endpoint system="OUT"/>
</chaining-router>
我是这样理解的,chaining-router的时候,是先执行了script,然后脚本返回后,才执行的stdio,输出到了控制台。
分享到:
相关推荐
自己翻译的Mule 2.x Getting Started Guide的文档,里边很多翻译的不是很好,各位需要的可以下载看一下,内容大多是对Mule进行简单的介绍!
ESB解决方案-mule分享.docxESB解决方案-mule分享.docxESB解决方案-mule分享.docxESB解决方案-mule分享.docxESB解决方案-mule分享.docxESB解决方案-mule分享.docxESB解决方案-mule分享.docxESB解决方案-mule分享.docx
GomPlayer类似于KMplayer,同样也是一款来自韩国播放器,界面精美、功能全面。多媒体播放器GOMPlayer... 以‘查找解码’功能来支持所有视频的播放,在BT或e-mule等P2P网站中下载的影片会经常不能播放,GOM Player以独
Mule讲解.docxMule讲解.docx
2) 支持BT或e-mule等P2P站点中接收到损坏的文件, 因中断页传送完成的文件, 索引损坏的AVI文件的播放. 3) 想截取的视频画面可以储存为图像 (JPG, BMP)文件, 还可以通过连续截图取功能来实现把影片的场景以帧为单位, ...
NULL 博文链接:https://lonely.iteye.com/blog/601103
包含http、cxf、vm、sap、activeMq、ftp、file、poll、Smtp、attachment、melExpression、Java、template节点的使用示例等。
弹性APM Mule3代理介绍此插件允许使用Elastic APM监视Mule 3.x组件的应用程序性能。 它提供了一种非侵入性的方式来度量和基准化Mule中的各个流程和步骤,并添加了对Mule组件的应用程序性能监控,以与日志,指标和...
MULE与ServiceMix的区别的各种摘要
Manning.Mule.in.Action.2nd.Edition.Feb.2014.pdf 第二版 及 源码
The book closes with a set of chapterson the nuts and bolts of working with Mule. Readers can take Mule farther bylearning techniques for testing, performance tuning, BPM orchestration, andeven a ...
Mule2编译指南 博文链接:https://netfly.iteye.com/blog/222123
EIP经典案例Load Broker————Mule ESB实践
mule 是java 实现ESB 的开源工程, 让你实现牛X的企业总线, 第2版的事mule in action....
。
David Dossot is a software architect and has created numerous modules and transports for Mule. John D’Emic is a principal solutions architect and Victor Romero a solutions architect, both at MuleSoft...
浅谈Mule ESB架构设计.doc