<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
	xmlns:int="http://www.springframework.org/schema/integration"
	xsi:schemaLocation="http://www.springframework.org/schema/integration/ip https://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd
		http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">

	<int-ip:tcp-connection-factory
			id="scf"
			type="server"
			so-timeout="60000"
			port="0" />

	<int-ip:tcp-inbound-channel-adapter
		connection-factory="scf"
		channel="inbound"/>

	<int:channel id="inbound">
		<int:queue/>
	</int:channel>

	<int-ip:tcp-outbound-channel-adapter
		connection-factory="scf"
		channel="replies" />

	<int:channel id="replies" />

	<!-- Since we use OS-assigning port in the server, this definition is for example.
	The real port is assigned to client in test code via reflection. -->
	<int-ip:tcp-connection-factory
			id="ccf"
			type="client"
			host="localhost"
			port="#{scf.port}"
			so-timeout="60000" />

	<bean id="caching.ccf" class="org.springframework.integration.ip.tcp.connection.CachingClientConnectionFactory">
		<constructor-arg ref="ccf" />
		<constructor-arg value="10" />
		<property name="connectionWaitTimeout" value="10000"/>
	</bean>

	<int-ip:tcp-outbound-channel-adapter
		connection-factory="caching.ccf"
		channel="outbound"/>

	<int:channel id="outbound" />

	<!-- Since we use OS-assigning port in the server, this definition is for example.
	The real port is assigned to client in test code via reflection. -->
	<int-ip:tcp-connection-factory
		id="gateway.ccf"
		type="client"
		host="localhost"
		port="#{scf.port}"
		so-timeout="60000"
	/>

	<bean id="gateway.caching.ccf" class="org.springframework.integration.ip.tcp.connection.CachingClientConnectionFactory">
		<constructor-arg ref="gateway.ccf" />
		<constructor-arg value="10" />
		<property name="connectionWaitTimeout" value="10000"/>
	</bean>

	<int-ip:tcp-outbound-gateway
		id="ob.gw"
		connection-factory="gateway.caching.ccf"
		request-channel="toGateway"
		reply-channel="fromGateway" />

	<int:channel id="toGateway" />

	<int:channel id="fromGateway">
		<int:queue/>
	</int:channel>
</beans>
