You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetConnection.java
+18-17Lines changed: 18 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2001-2018 the original author or authors.
2
+
* Copyright 2001-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardExpand all lines: spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java
+37-33Lines changed: 37 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2002-2018 the original author or authors.
2
+
* Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -115,7 +115,7 @@ public void setPipeTimeout(long pipeTimeout) {
@@ -371,6 +373,8 @@ The following example shows a client connection factory that uses `java.net.Sock
371
373
----
372
374
====
373
375
376
+
==== Message Demarcation (Serializers and Deserializers)
377
+
374
378
TCP is a streaming protocol.
375
379
This means that some structure has to be provided to data transported over TCP so that the receiver can demarcate the data into discrete messages.
376
380
Connection factories are configured to use serializers and deserializers to convert between the message payload and the bits that are sent over TCP.
@@ -437,6 +441,8 @@ This is similar to the deserializer side of `ByteArrayRawSerializer` above, exce
437
441
Internally, it uses a `ByteArrayOutputStream` that lets the buffer grow as needed.
438
442
The client must close the socket in an orderly manner to signal end of message.
439
443
444
+
WARNING: This deserializer should only be used when the peer is trusted; it is susceptible to a DoS attach due to out of memory conditions.
445
+
440
446
The `MapJsonSerializer` uses a Jackson `ObjectMapper` to convert between a `Map` and JSON.
441
447
You can use this serializer in conjunction with a `MessageConvertingTcpMessageMapper` and a `MapMessageConverter` to transfer selected headers and the payload in JSON.
442
448
@@ -447,8 +453,6 @@ By default, a `ByteArrayLfSerializer` is used, resulting in messages with a form
447
453
The final standard serializer is `org.springframework.core.serializer.DefaultSerializer`, which you can use to convert serializable objects with Java serialization.
448
454
`org.springframework.core.serializer.DefaultDeserializer` is provided for inbound deserialization of streams that contain serializable objects.
449
455
450
-
To implement a custom serializer and deserializer pair, implement the `org.springframework.core.serializer.Deserializer` and `org.springframework.core.serializer.Serializer` interfaces.
451
-
452
456
If you do not wish to use the default serializer and deserializer (`ByteArrayCrLfSerializer`), you must set the `serializer` and `deserializer` attributes on the connection factory.
453
457
The following example shows how to do so:
454
458
@@ -480,6 +484,15 @@ NOTE: You can also modify the attributes of sockets and socket factories.
480
484
See <<ssl-tls>>.
481
485
As noted there, such modifications are possible whether or not SSL is being used.
482
486
487
+
==== Custom Serializers and Deserializers
488
+
489
+
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.
490
+
491
+
To implement a custom serializer and deserializer pair, implement the `org.springframework.core.serializer.Deserializer` and `org.springframework.core.serializer.Serializer` interfaces.
492
+
493
+
When the deserializer detects a closed input stream between messages, it must throw a `SoftEndOfStreamException`; this is a signal to the framework to indicate that the close was "normal".
494
+
If the stream is closed while decoding a message, some other exception should be thrown instead.
0 commit comments