mule配置tcp

配置文件:

<mule xmlns="http://www.mulesource.org/schema/mule/core/2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:file="http://www.mulesource.org/schema/mule/file/2.1"
xmlns:tcp="http://www.mulesource.org/schema/mule/tcp/2.1"
xmlns:xm="http://www.mulesource.org/schema/mule/xml/2.1"
xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.1"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.1 http://www.mulesource.org/schema/mule/core/2.1/mule.xsd
http://www.mulesource.org/schema/mule/file/2.1 http://www.mulesource.org/schema/mule/file/2.1/mule-file.xsd
http://www.mulesource.org/schema/mule/tcp/2.1 http://www.mulesource.org/schema/mule/tcp/2.1/mule-tcp.xsd
http://www.mulesource.org/schema/mule/xml/2.1 http://www.mulesource.org/schema/mule/xml/2.1/mule-xml.xsd
http://www.mulesource.org/schema/mule/stdio/2.1 http://www.mulesource.org/schema/mule/stdio/2.1/mule-stdio.xsd">
<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="127.0.0.1" port="5200" synchronous="true"/>
<model name="tcpModel">
<service name="tcpService">
<inbound>
<tcp:inbound-endpoint name="inboundEndpoint" connector-ref="TcpConnector" host="127.0.0.1" port="5200" />
</inbound>
<outbound>
<pass-through-router>
<file:outbound-endpoint path="./out" outputPattern="EMAIL-[DATE].txt"/>
</pass-through-router>
</outbound>
</service>
</model>
</mule>

客户端访问:

package org;

import java.net.*;
import java.io.*;

public class Client {

public static void main(String[] args) throws Exception {
Socket server = new Socket(InetAddress.getByName("127.0.0.1"), 5200);
BufferedReader in = new BufferedReader(new InputStreamReader(server
.getInputStream()));
PrintWriter out = new PrintWriter(server.getOutputStream());
String str = "aaa";
out.println(str);
out.flush();
server.close();
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值