mule入门 xmpp tcp 配置 之 xml配置

mule做了一周多了,入门很难,光跑那几个demo就很费事情,它提供的很多东西都和文档上的不一致,这点真的想骂人,不成熟的东西就不要拿出来啊,拿出来又用不起,老板又不听这种解释。。。。我真的苦啊!!!

 

不过总算过头了,我成功的调通了mule的xmpp路由功能,虽然里面有bug,但我自己写了一个类的代替它,勉强可以用了。

下面我把如何配置xml文件以及如果启动告诉大家,希望对大家有些帮助,不用再花费太多时间去研究!

下面是一个完整可运行的,通过测试的xml



 ,

 

 

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:spring="http://www.springframework.org/schema/beans"
       xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
       xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2"
       xmlns:tcp="http://www.mulesource.org/schema/mule/tcp/2.2"
       xsi:schemaLocation="
               http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
               http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd
               http://www.mulesource.org/schema/mule/tcp/2.2 http://www.mulesource.org/schema/mule/tcp/2.2/mule-tcp.xsd
               http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd">

    <custom-transformer name="StdinToNameString" class="org.mule.example.hello.StdinToNameString"/>
    <custom-transformer name="NameStringToChatString" class="org.mule.example.hello.NameStringToChatString"/>
    <custom-transformer name="ChatStringToString" class="org.mule.example.hello.ChatStringToString"/>
    <custom-transformer name="ExceptionToString" class="org.mule.example.hello.ExceptionToString"/>
    <custom-transformer name="StringToString" class="transformer.StringToString"></custom-transformer>
    <custom-transformer name="XmppPacketToObject" class="org.mule.transport.xmpp.transformers.XmppPacketToObject"/>
    <custom-transformer name="ObjectToXmppPacket" class="org.mule.transport.xmpp.transformers.ObjectToXmppPacket"/>
    <custom-transformer name="XmppPacketToString" class="xmpp.XmppPacketToString"/>
    <custom-transformer name="ByteArrayToObject" class="org.mule.transformer.simple.ByteArrayToObject"/>
   
    <custom-transformer name="ObjectToTempXmppPacket" class="xmpp.ObjectToTempXmppPacket"/>
   
    <!--
        An interceptor is a piece of code that can be configured to execute
        before and/or after an event is received for a component.
        You can define a stack of interceptors that will be executed in sequence.
        You can then configure the stack on your components.
    -->

    <!--
        The Mule model initialises and manages your UMO components
    -->

     <tcp:connector name="TcpConnector"
             keepAlive="true" receiveBufferSize="2048" sendBufferSize="2048"
            receiveBacklog="500" serverSoTimeout="3000"
            keepSendSocketOpen="true"  validateConnections="true">
            <tcp:direct-protocol payloadOnly="true"/>
          
    </tcp:connector>
   
    <tcp:endpoint connector-ref="TcpConnector" name="Endpoint" host="192.168.1.20" port="5200" synchronous="true"/>

    <model name="helloSample">
        <!--
            A Mule service defines all the necessary information about how your components will
            interact with the framework, other components in the system and external sources.
            Please refer to the Configuration Guide for a full description of all the parameters.
        -->
        <service name="GreeterUMO">
            <inbound>
                    <tcp:inbound-endpoint name="inboundEndpoint"  connector-ref="TcpConnector"
                        port="5200"  host="192.168.1.20" transformer-refs="ByteArrayToObject ObjectToTempXmppPacket"/>             
<!--                 <inbound-endpoint ref="inboundEndpoint"/>-->
            </inbound>
           
<!--            <component class="xmpp.XmppOtherComponet"/>-->

            <outbound>
                <filtering-router>
                    <vm:outbound-endpoint path="iq"/>
                    <payload-type-filter expectedType="beans.Person"/>
                </filtering-router>
                <filtering-router>
                    <vm:outbound-endpoint path="iq"/>
                    <payload-type-filter expectedType="qflag.xmpp.packet.IQ"/>
                </filtering-router>
                <filtering-router>
                    <vm:outbound-endpoint path="message"/>
                    <payload-type-filter expectedType="qflag.xmpp.packet.Message"/>
                </filtering-router>
<!--                <filtering-router>-->
<!--                    <vm:outbound-endpoint path="message"/>-->
<!--                    <payload-type-filter expectedType="qflag.xmpp.packet.IQ"/>-->
<!--                </filtering-router>-->
               
               
                 <filtering-router>
                     <vm:outbound-endpoint path="userErrorHandler"/>
                    <payload-type-filter expectedType="java.lang.Exception"/>
                </filtering-router>
            </outbound>

            <!-- Route unexpected errors to separate error handler -->
            <default-service-exception-strategy>
                <vm:outbound-endpoint path="systemErrorHandler"/>
            </default-service-exception-strategy>
        </service>

        <service name="IQUMO">

            <inbound>
                <vm:inbound-endpoint path="iq" responseTransformer-refs="StringToString" />
            </inbound>
               
           <component class="xmpp.service.IQService" />
           <!-- Route unexpected errors to separate error handler -->
            <default-service-exception-strategy>
                <vm:outbound-endpoint path="systemErrorHandler"/>
            </default-service-exception-strategy>
        </service>
       
        <service name="MessageUMO">

            <inbound>
                <vm:inbound-endpoint path="message" />
            </inbound>
            
            <component class="xmpp.service.MessageService"/>
          
            <!-- Route unexpected errors to separate error handler -->
            <default-service-exception-strategy>
                <vm:outbound-endpoint path="systemErrorHandler"/>
            </default-service-exception-strategy>
        </service>
       
       
        <!-- This error handler returns user error messages to caller. Errors could also be routed elsewhere,
            e.g. into an error file, send via email to a list, stored in a database, etc. -->
        <service name="UserErrorHandler">
            <inbound>
                <vm:inbound-endpoint path="userErrorHandler" transformer-refs="ExceptionToString"/>
            </inbound>
           
            <outbound>
                <pass-through-router>
                    <stdio:outbound-endpoint system="OUT"/>
                </pass-through-router>
            </outbound>
        </service>
               
        <!-- Handle any unexpected errors. Errors could also be routed elsewhere,
            e.g. into an error file, send via email to a list, stored in a database, etc. -->
        <service name="SystemErrorHandler">
            <inbound>
                <vm:inbound-endpoint path="systemErrorHandler"/>
            </inbound>
               
            <outbound>
                <pass-through-router>
                    <stdio:outbound-endpoint system="ERR"/>
                </pass-through-router>
            </outbound>
        </service>       
    </model>


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值