INT-3574: File Outbound - Don't Flush File

JIRA: https://jira.spring.io/browse/INT-3574

Initial commit.

Polishing

Prevent the flusher task from closing while a write is in process.

Add MessageTriggerAction

Flush file(s) on demand.

Polishing - PR Comments

Add FlushPredicate

Polishing - PR Comments

Polishing - More PR Comments and Schema

Polish and Namespace

Docs

flushIfNeeded Must be Synchronized

Fix Race on Stop

Flush immediately after the write if the handler has been stopped.

Remove states from the internal store if handler is stopped.
This commit is contained in:
Gary Russell
2016-01-12 16:22:43 -05:00
committed by Artem Bilan
parent 884aebcb07
commit c7724c340c
11 changed files with 635 additions and 32 deletions

View File

@@ -438,7 +438,10 @@ This class can deal with the following payload types:
You can configure the encoding and the charset that will be used in case of a String payload.
To make things easier, you can configure the `FileWritingMessageHandler` as part of an _Outbound Channel Adapter_ or _Outbound Gateway_ using the provided XML namespace support.
To make things easier, you can configure the `FileWritingMessageHandler` as part of an _Outbound Channel Adapter_ or
_Outbound Gateway_ using the provided XML namespace support.
Starting with _version 4.3_, you can specify the buffer size to use when writing files.
[[file-writing-file-names]]
==== Generating File Names
@@ -524,6 +527,7 @@ The following options exist:
* REPLACE (Default)
* APPEND
* APPEND_NO_FLUSH
* FAIL
* IGNORE
@@ -539,7 +543,15 @@ If the _mode_ attribute is not specified, then this is the default behavior when
_APPEND_
This mode allows you to append Message content to the existing file instead of creating a new file each time.
Note that this attribute is mutually exclusive with _temporary-file-suffix_ attribute since when appending content to the existing file, the adapter no longer uses a temporary file.
Note that this attribute is mutually exclusive with _temporary-file-suffix_ attribute since when appending content to
the existing file, the adapter no longer uses a temporary file.
The file is closed after each message.
__APPEND_NO_FLUSH__
This has the same semantics as *APPEND* but the data is not flushed and the file is not closed after each message.
This can provide a significant performance at the risk of data loss in the case of a failure.
See <<file-flushing>> for more information.
_FAIL_
@@ -551,6 +563,27 @@ If the target file exists, the message payload is silently ignored.
NOTE: When using a temporary file suffix (default: `.writing`), the _IGNORE_ mode will apply if the final file name exists, or the temporary file name exists.
[[file-flushing]]
==== Flushing Files When using APPEND_NO_FLUSH
The *APPEND_NO_FLUSH* mode was added in _version 4.3_.
This can improve performance because the file is not closed after each message.
However, this can cause data loss in the event of a failure.
Several flushing strategies, to mitigate this data loss, are provided:
- `flushInterval` - if a file is not written to for this period of time, it is automatically flushed.
This is approximate and may be up to `1.33x` this time.
- Send a message to the message handler's `trigger` method containing a regular expression.
Files with absolute path names matching the pattern will be flushed.
- Provide the handler with a custom `MessageFlushPredicate` implementation to modify the action taken when a message
is sent to the `trigger` method.
- Invoke one of the handler's `flushIfNeeded` methods passing in a custom `FileWritingMessageHandler.FlushPredicate`
or `FileWritingMessageHandler.MessageFlushPredicate` implementation.
The predicates are called for each open file.
See the java docs for these interfaces for more information.
[[file-outbound-channel-adapter]]
==== File Outbound Channel Adapter

View File

@@ -86,7 +86,7 @@ For this reason, users should not perform such manipulation, or set the `copyOnG
=====
[[message-group-factory]]
===== MessageGroupFactory
==== MessageGroupFactory
Starting with _version 4.3_, some `MessageGroupStore` implementations can be injected with a custom
`MessageGroupFactory` strategy to create/customize the `MessageGroup` instances used by the `MessageGroupStore`.

View File

@@ -57,10 +57,21 @@ See <<udp-adapters>> for more information.
==== File Changes
===== Destination Directory Creation
The generated file name for the `FileWritingMessageHandler` can represent _sub-path_ to save the desired directory
structure for file in the target directory.
See <<file-writing-file-names>> for more information.
===== Buffer Size
When writing files, you can now specify the buffer size to use.
===== Appending and Flushing
You can now avoid flushing files when appending and use a number of strategies to flush the data during idle periods.
See <<file-flushing>> for more information.
==== AMQP Changes
The outbound endpoints now support a `RabbitTemplate` configured with a `ContentTypeDelegatingMessageConverter` such