UDP
Spring Integration supports both one-way and two-way communication using UDP-based protocol using channel adapters and message gateways respectively.
Listing 22-34 below shows maven dependency required for integrating UDP-protocol application using Spring Integration.
Listing 22-34. Maven dependency required
1 2 3 4 5 6 7 8 9 |
<dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-ip</artifactId> <version>${spring-integration-version}</version> </dependency> |
Listing 22-35 below shows configuration of main Spring Integration namespace and UDP (ip) related namespace in the Spring configuration file (file-integration-context.xml).
Listing 22-35. Spring Integration Namespace declaration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?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="http://www.springframework.org/schema/integration" xmlns: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/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip-2.1.xsd"> … </beans> |
Listing 22-36 below shows configuration of a basic UDP adapter in the Spring configuration file (udp-integration-context.xml).
Listing 22-36. Basic inbound and outbound udp adpater configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<beans …> … <int:channel id="sendUdpChannel"/> <int:channel id="receiveUdpChannel"/> <ip:udp-outbound-channel-adapter id="outboundUdp" host="localhost" port="9999" multicast="false" check-length="true" channel="sendUdpChannel"/> <ip:udp-inbound-channel-adapter id="inboundUdp" port="9999" receive-buffer-size="100" multicast="false" check-length="true" channel="receiveUdpChannel" /> … </beans> |
TCP
Spring Integration also supports one-way and two-way communication using TCP-based protocol by configuring channel adapters and message gateways accordingly. Maven dependency and the Spring Integration namespace is same as detailed in the previous section, “UDP”.
Listing 22-37 below shows configuration of a basic TCP adapter in the Spring configuration file (tcp-integration-context.xml). Connection used by the TCP adapters can be configured using the two TCP connections factories, one for the client used for creating an outgoing connection and one for the server used to listen for an incoming connection.
Listing 22-37. Basic inbound and outbound tcp adpater configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<beans …> … <int:channel id="sendTcpChannel"/> <int:channel id="receiveTcpChannel"/> <ip:tcp-connection-factory id="clientConnFactory" type="client" host="localhost" port="9999" single-use="true" so-timeout="5000"/> <ip:tcp-connection-factory id="serverConnFactory" type="server" host="localhost" port="9999"/> <ip:tcp-outbound-channel-adapter id="outboundTcpAdapter" channel="sendTcpChannel" connection-factory="clientConnFactory"/> <ip:tcp-inbound-channel-adapter id="inboundTcpAdapter" channel="receiveTcpChannel" connection-factory="serverConnFactory"/> … </beans> |
Page Visitors: 13117

Tomcy John

Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023
Hi,
Thanks for this blog and information sharing!
I have one question from Spring Integration. Just thought of checking with you.
I have SimplewebserviceOutBoundGateway. I need to send a document / attachment to the webservice. How will i achieve that?
This is my current gateway configuration:
Please let me know, if you can throw some light in this area.
Thanks in Advance!
Hi,
Thank you for your information sharing.
I have one doubt,could you please suggest me the correct frameworks to address that issue.
My requirement is I would like to get and process files using spring and camel.
Thanks,
Madhu