Skip to content

Commit 23e277d

Browse files
garyrussellartembilan
authored andcommitted
GH-3477: Add DSL Docs for TCP Components
Resolves #3477 **cherry-pick to 5.4.x** (cherry picked from commit f223343)
1 parent d4a4e24 commit 23e277d

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

src/reference/asciidoc/ip.adoc

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ The following example shows a client connection factory that uses `java.net.Sock
381381

382382
Starting with version 5.2, the client connection factories support the property `connectTimeout`, specified in seconds, which defaults to 60.
383383

384+
Also see <<ip-annotation>> and <<ip-dsl>>.
385+
384386
[[tcp-codecs]]
385387
==== Message Demarcation (Serializers and Deserializers)
386388

@@ -496,6 +498,8 @@ NOTE: You can also modify the attributes of sockets and socket factories.
496498
See <<ssl-tls>> for more information.
497499
As noted there, such modifications are possible whether or not SSL is being used.
498500

501+
Also see <<ip-annotation>> and <<ip-dsl>>.
502+
499503
==== Custom Serializers and Deserializers
500504

501505
If your data is not in a format supported by one of the standard deserializers, you can implement your own; you can also implement a custom serializer.
@@ -815,6 +819,8 @@ The following example shows how to define client and server TCP connection facto
815819
----
816820
====
817821

822+
Also see <<ip-annotation>> and <<ip-dsl>>.
823+
818824
In the preceding configuration, messages arriving in the `input` channel are serialized over connections created by `client` connection factory, received at the server, and placed on the `loop` channel.
819825
Since `loop` is the input channel for `outboundServer`, the message is looped back over the same connection, received by `inboundClient`, and deposited in the `replies` channel.
820826
Java serialization is used on the wire.
@@ -923,6 +929,8 @@ To support this on the server side, you can now register multiple `TcpSender` s
923929
Gateways and Channel Adapters automatically register themselves.
924930
When sending unsolicited messages from the server, you must add the appropriate `IpHeaders.CONNECTION_ID` to the messages sent.
925931

932+
Also see <<ip-annotation>> and <<ip-dsl>>.
933+
926934
[[ip-correlation]]
927935
=== TCP Message Correlation
928936

@@ -2247,3 +2255,73 @@ In this scenario, the `@ServiceActivator` configures the endpoint, according to
22472255
22482256
<8> The server-side connection factory.
22492257
====
2258+
2259+
[[ip-dsl]]
2260+
=== Using the Java DSL for TCP Components
2261+
2262+
DSL support for TCP components includes specs for adapters and gateways, the `Tcp` class with factory methods to create connection factory beans, and the `TcpCodecs` class with factory methods to create serializers and deserializers.
2263+
Refer to their javadocs for more information.
2264+
2265+
Here are some examples of using the DSL to configure flows using the DSL.
2266+
2267+
.Server Adapter Flow
2268+
====
2269+
[source, java]
2270+
----
2271+
@Bean
2272+
public IntegrationFlow server() {
2273+
return IntegrationFlows.from(Tcp.inboundAdapter(Tcp.netServer(1234)
2274+
.deserializer(TcpCodecs.lengthHeader1())
2275+
.backlog(30))
2276+
.errorChannel("tcpIn.errorChannel")
2277+
.id("tcpIn"))
2278+
.transform(Transformers.objectToString())
2279+
.channel("tcpInbound")
2280+
.get();
2281+
}
2282+
----
2283+
====
2284+
2285+
.Client Adapter Flow
2286+
====
2287+
[source, java]
2288+
----
2289+
@Bean
2290+
public IntegrationFlow client() {
2291+
return f -> f.handle(Tcp.outboundAdapter(Tcp.nioClient("localhost", 1234)
2292+
.serializer(TcpCodecs.lengthHeader1())));
2293+
}
2294+
----
2295+
====
2296+
2297+
.Server Gateway Flow
2298+
====
2299+
[source, java]
2300+
----
2301+
@Bean
2302+
public IntegrationFlow server() {
2303+
return IntegrationFlows.from(Tcp.inboundGateway(Tcp.netServer(1234)
2304+
.deserializer(TcpCodecs.lengthHeader1())
2305+
.serializer(TcpCodecs.lengthHeader1())
2306+
.backlog(30))
2307+
.errorChannel("tcpIn.errorChannel")
2308+
.id("tcpIn"))
2309+
.transform(Transformers.objectToString())
2310+
.channel("tcpInbound")
2311+
.get();
2312+
}
2313+
----
2314+
====
2315+
2316+
.Client Gateway Flow
2317+
====
2318+
[source, java]
2319+
----
2320+
@Bean
2321+
public IntegrationFlow client() {
2322+
return f -> f.handle(Tcp.outboundGateway(Tcp.nioClient("localhost", 1234)
2323+
.deserializer(TcpCodecs.lengthHeader1())
2324+
.serializer(TcpCodecs.lengthHeader1())));
2325+
}
2326+
----
2327+
====

0 commit comments

Comments
 (0)