Files
spring-integration-samples/basic/tcp-with-headers
2019-12-04 15:33:04 -05:00
..
2019-03-25 12:49:27 -04:00
2019-03-25 12:49:27 -04:00
2019-12-04 15:33:04 -05:00
2019-03-25 12:49:27 -04:00

= TCP With Headers

There is no standard way to convey message headers over raw TCP; they need to be encoded into the payload on the sending side and decoded on the receiving side.

This example demonstrates how to use standard framework components to encode the payload and certain headers using JSON.
It takes console input and, if the input starts with a lower case, uppercases it and vice versa.
Whether to upper case or lower case the input is conveyed in a header 'type'.

Run from your favorite IDE, or from the command line `./gradlew :dynamic-tcp-client:run`.

Here is an example run...

```
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.3.RELEASE)

Enter some text; if it starts with a lower case character,
it will be uppercased by the server; otherwise it will be lowercased;
enter 'quit' to end
this should be uppercased
10:54:39.259 [pool-1-thread-2] INFO  exampleLogger - Received type header:upper
THIS SHOULD BE UPPERCASED
This should be lowercased
10:54:49.266 [pool-1-thread-2] INFO  exampleLogger - Received type header:lower
this should be lowercased
quit
```