Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p" xmlns:int="http://www.springframework.org/schema/integration"
- xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.2.xsd
- http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip-2.2.xsd
- ">
- <!-- A base package to be scanned for looking Injections. -->
- <context:component-scan base-package="org.example.tcpclient" />
- <!-- Enables the annotations. -->
- <context:annotation-config />
- <!-- Declares a serializer/deserializer to be used. -->
- <bean id="byteArrayLenSerializer"
- class="org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSerializer" />
- <!-- Defines a response Handler -->
- <bean id="responseHandler"
- class="org.example.tcpclient.TcpClientMessageHandler" />
- <!-- Wraps a service with two reply-request channels. -->
- <int:gateway id="client"
- service-interface="org.example.tcpclient.TcpClientService"
- default-reply-channel="replyChannel"
- default-request-channel="requestChannel"
- default-reply-timeout="1000"
- default-request-timeout="1000">
- </int:gateway>
- <!-- Request channel -->
- <int:channel id="requestChannel">
- <int:queue capacity="10" />
- </int:channel>
- <!-- Direct channel used for reply. -->
- <int:channel id="replyChannel" />
- <int-ip:tcp-connection-factory id="tcpClient"
- type="client"
- host="localhost"
- port="23234"
- single-use="false"
- so-timeout="30000"
- serializer="byteArrayLenSerializer"
- deserializer="byteArrayLenSerializer"
- interceptor-factory-chain="clientInterceptorFactoryChain" />
- <!-- Our implementation of the interceptor. -->
- <bean id="tcpClientConnectionInterceptorFactory"
- class="org.example.tcpclient.TcpClientInterceptorFactory"
- p:outputChannel-ref="requestChannel" />
- <!-- Adds behavior to connections. Triggers on the following events: onConnect,
- onDisconnect.
- -->
- <bean id="clientInterceptorFactoryChain"
- class="org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorFactoryChain">
- <property name="interceptors">
- <array>
- <ref bean="tcpClientConnectionInterceptorFactory" />
- </array>
- </property>
- </bean>
- <!-- A default poller. -->
- <int:poller max-messages-per-poll="1" id="defaultPoller"
- default="true" fixed-rate="300" />
- <!-- TCP outbound adaptor, a client mode. -->
- <int-ip:tcp-outbound-channel-adapter id="clientTcpOutAdaptor"
- channel="requestChannel"
- connection-factory="tcpClient"
- client-mode="true"
- phase="0" />
- <!-- TCP inbound adaptor. -->
- <int-ip:tcp-inbound-channel-adapter id="clientTcpInAdaptor"
- channel="replyChannel"
- connection-factory="tcpClient"
- client-mode="true"
- phase="1"
- retry-interval="10000" />
- <!-- A service activator for message handler. -->
- <int:service-activator input-channel="replyChannel"
- ref="responseHandler"
- method="handle" />
- </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement