Advertisement
olegtikhonov

client-config.xml

Apr 1st, 2013
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:p="http://www.springframework.org/schema/p" xmlns:int="http://www.springframework.org/schema/integration"
  5. xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  7. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  8. http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.2.xsd
  9. http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip-2.2.xsd
  10. ">
  11.  
  12. <!-- A base package to be scanned for looking Injections. -->
  13. <context:component-scan base-package="org.example.tcpclient" />
  14.  
  15. <!-- Enables the annotations. -->
  16. <context:annotation-config />
  17.  
  18. <!-- Declares a serializer/deserializer to be used. -->
  19. <bean id="byteArrayLenSerializer"
  20. class="org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSerializer" />
  21.  
  22. <!-- Defines a response Handler -->
  23. <bean id="responseHandler"
  24. class="org.example.tcpclient.TcpClientMessageHandler" />
  25.  
  26.  
  27. <!-- Wraps a service with two reply-request channels. -->
  28. <int:gateway id="client"
  29. service-interface="org.example.tcpclient.TcpClientService"
  30. default-reply-channel="replyChannel"
  31. default-request-channel="requestChannel"
  32. default-reply-timeout="1000"
  33. default-request-timeout="1000">
  34. </int:gateway>
  35.  
  36. <!-- Request channel -->
  37. <int:channel id="requestChannel">
  38. <int:queue capacity="10" />
  39. </int:channel>
  40.  
  41.  
  42. <!-- Direct channel used for reply. -->
  43. <int:channel id="replyChannel" />
  44.  
  45.  
  46. <int-ip:tcp-connection-factory id="tcpClient"
  47. type="client"
  48. host="localhost"
  49. port="23234"
  50. single-use="false"
  51. so-timeout="30000"
  52. serializer="byteArrayLenSerializer"
  53. deserializer="byteArrayLenSerializer"
  54. interceptor-factory-chain="clientInterceptorFactoryChain" />
  55.  
  56. <!-- Our implementation of the interceptor. -->
  57. <bean id="tcpClientConnectionInterceptorFactory"
  58. class="org.example.tcpclient.TcpClientInterceptorFactory"
  59. p:outputChannel-ref="requestChannel" />
  60.  
  61.  
  62. <!-- Adds behavior to connections. Triggers on the following events: onConnect,
  63. onDisconnect.
  64. -->
  65. <bean id="clientInterceptorFactoryChain"
  66. class="org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorFactoryChain">
  67. <property name="interceptors">
  68. <array>
  69. <ref bean="tcpClientConnectionInterceptorFactory" />
  70. </array>
  71. </property>
  72. </bean>
  73.  
  74. <!-- A default poller. -->
  75. <int:poller max-messages-per-poll="1" id="defaultPoller"
  76. default="true" fixed-rate="300" />
  77.  
  78. <!-- TCP outbound adaptor, a client mode. -->
  79. <int-ip:tcp-outbound-channel-adapter id="clientTcpOutAdaptor"
  80. channel="requestChannel"
  81. connection-factory="tcpClient"
  82. client-mode="true"
  83. phase="0" />
  84.  
  85. <!-- TCP inbound adaptor. -->
  86. <int-ip:tcp-inbound-channel-adapter id="clientTcpInAdaptor"
  87. channel="replyChannel"
  88. connection-factory="tcpClient"
  89. client-mode="true"
  90. phase="1"
  91. retry-interval="10000" />
  92.  
  93.  
  94. <!-- A service activator for message handler. -->
  95. <int:service-activator input-channel="replyChannel"
  96. ref="responseHandler"
  97. method="handle" />
  98.  
  99. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement