Mule ESB的component(二)——Component的使用

一 Mule自带的component

打开mule的核心jar包mule-core-3.0.0.jar,可以看到如下结构,期中simple中的component即mule自带的component:


 

    1. bridge component

    mule中的每一个service中都会包含一个bridge component,它被隐式的引用了:


     定义:This is the bridge component. As its name suggests, it bridges its inbound router to its outbound router, but doesn’t perform any particular operation on the message.

    从定义中看,bridge component的作用是将message从inbound传递到outbound中,期间它对message没有任何操作。

 

    在《Mule-ESB-3-User-Guide》中找到一段关于PassThroughComponent的描述,bridge component的默认实现类应该就是PassThroughComponent:

Java代码   收藏代码
  1. Service Bridge  
  2. Service component configuration is optional in Mule 2.x. The default and implicit component used is PassThroughComponent . This component  
  3. automatically bridges inbound messages to the outbound phase and simply passes messages to the outbound routers. This approach is useful for  
  4. bridging endpoints if you want to pass a message from one transport to another.  

 

    2. echo component和log component

    两者都是为了记录信息,从源码中分析,两者的关联是EchoComponent extends LogComponent,前者调用父类的方法进行日志输出。两者的差别是:echo将message的信息全部输出,而log会默认截取前100个长度的信息。

 

    使用方法如下图,log component使用<log-component />替换<echo-component />:


 

    3. null component

    从源码中可以看到,当NullComponent接收到信息时,会抛出一个异常:

Java代码   收藏代码
  1. package org.mule.component.simple;  
  2.   
  3. import org.mule.api.MuleEventContext;  
  4. import org.mule.api.lifecycle.Callable;  
  5.   
  6. /** 
  7.  * <code>NullComponent</code> is a service that is used as a placeholder. This 
  8.  * implementation will throw an exception if a message is received for it. 
  9.  */  
  10. public class NullComponent implements Callable  
  11. {  
  12.   
  13.     public Object onCall(MuleEventContext context) throws Exception  
  14.     {  
  15.         throw new UnsupportedOperationException("This service cannot receive messages. Service is: "  
  16.                                                 + context.getFlowConstruct().getName());  
  17.     }  
  18.   
  19. }  

 

使用方法


    4. StaticComponent

    这个没有找到先关的资料,从api中可以看到该类的描述:

    A service that will return a static data object as a result. This is useful for testing with expected results. The data returned can be read from a file or set as a property on this service.

 

    这个component应该是mule用于测试时设置期望数据的组件。

 

二 远程调用

    mule支持远程调用,它支持RPC和REST两类调用,由于对这两块技术是空白,所以大家自己研究吧= =!

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值