INT-676 added documentation around:

multipart-file support,
long-polling,
delete-source-files in FileWritingMessageHandler
This commit is contained in:
Oleg Zhurakousky
2009-07-02 20:40:15 +00:00
parent 716f399370
commit 19a9764cd2
3 changed files with 47 additions and 2 deletions

View File

@@ -220,5 +220,22 @@ consumer.setTransactionManager(txManager);</programlisting>
provide a reference to any implementation of Spring's <interfacename>TaskExecutor</interfacename> interface by
specifying the bean name. The thread pool element is simply provided for convenience.
</para>
<para>
You can also use Polling consumers to emulate event-driven semantics. With a long receive-timeout and a short trigger
interval you can effectively approximate event-driven behavior even for a polled message source.
</para>
<para>
A good use case that shows how this approach could be aplied is event-driven files via <code>inbound-channel-adapter</code> where drop of the
file into a directory woudl essentially become an event for that file to be picked up and sent throught the process.
<programlisting language="xml"><![CDATA[<file:inbound-channel-adapter id="filesIn"
directory="file:${input.directory.property}">
<si:poller receive-timeout="30000">
<si:interval-trigger interval="10"/>
</si:poller>
</file:inbound-channel-adapter>]]></programlisting>
Using this approach does not carry much overhead since internally it is nothing more then a timed-wait thread which does not use much of CPU resurces
</para>
</section>
</chapter>

View File

@@ -126,6 +126,27 @@
using the namespace.
<programlisting language="xml"><![CDATA[<file:outbound-channel-adapter id="filesOut" directory="file:${input.directory.property}"/>]]></programlisting>
</para>
<para>
Namespace based configuration also supports <code>delete-source-files</code> attribute which if set to <code>true</code>
will trigger deletion of the original source files after writing to a destination.
The default value for that flag is <code>false</code>
<programlisting language="xml"><![CDATA[<file:outbound-channel-adapter id="filesOut" directory="file:${input.directory.property}"
delete-source-files="true"/>]]></programlisting>
<note>
<para>
The <code>delete-source-files</code> attribute will only have an effect if the inbound Message has a File payload or
<classname>FileHeaders.ORIGINAL_FILE</classname> header value containing either a File instance or a String representing the original file path.
</para>
</note>
</para>
<para>
In cases where you want to continue processing messages based on the written File you can use <code>outbound-gateway</code> which plays a very similar role
as the <code>outbound-channel-adapter</code>. However instead of writing a file It will send it over to the reply channel
<programlisting language="xml"><![CDATA[<file:outbound-gateway id="mover" request-channel="moveInput"
reply-channel="output"
directory="${java.io.tmpdir}/anyDir"
delete-source-files="true"/>]]></programlisting>
</para>
<para>
If you have more elaborate requirements to the payload to file
conversion you could extend the FileWritingMessageHandler, but a

View File

@@ -24,17 +24,21 @@
</bean>]]></programlisting>
The <classname>HttpInboundEndpoint</classname> accepts an instance of <interfacename>InboundRequestMapper</interfacename> which allows
customisation of the mapping from <interfacename>HttpServletRequest</interfacename> to <interfacename>Message</interfacename>. If none is
provided the an instance of <classname>DefaultInboundRequestMapper</classname> will be used. This encapsulates a simple strategy, which for
provided an instance of <classname>DefaultInboundRequestMapper</classname> will be used. This encapsulates a simple strategy, which for
example will create a String message for a <emphasis>POST</emphasis> request where the content type starts with "text", see the Javadoc for
full details.
</para>
<para>Starting with this release MultiPart File support was implemented. If the request has been wrapped as a <emphasis>MultipartHttpServletRequest</emphasis>,
then the 'content type' can be checked. If it is known, and begins with "text", then the <emphasis>MultipartFile</emphasis> can be copied to a String in the parameter
map. If the 'content type does not begin with "text", then the <emphasis>MultipartFile</emphasis> can be copied to a byte array within the parameter map instead.
</para>
<para>
In sending a response to the client there are a number of ways to customise the behaviour of the gateway. By default the gateway will
simply acknowledge that the request was received by sending a 200 status code back. It is possible to customise this response by providing an
implementation of the Spring MVC <interfacename>View</interfacename> which will be invoked with the created <interfacename>Message</interfacename>.
In the case that the gateway should expect a reply to the <interfacename>Message</interfacename> then setting the <property>expectReply</property> flag will cause
the gateway to wait for a response <interfacename>Message</interfacename> before creating an Http response. Below is an example of a gateway
configured to use a custom view and to wait for a response. It also shows how to customise the Http methods accepted by the gateway, which
configured to use a custom view and to wait for a response. It also shows how to customise the Http methods accepted by the gateway, which
are <emphasis>POST</emphasis> and <emphasis>GET</emphasis> by default.
<programlisting language="xml"><![CDATA[<bean id="httpInbound" class="org.springframework.integration.http.HttpInboundEndpoint">
<property name="requestChannel" ref="httpRequestChannel" />
@@ -53,6 +57,9 @@
for that map entry by default is 'requestMessage', but this can be overridden by setting the
'requestKey' property on the endpoint's configuration.
</para>
<para>
Starting wit this release
</para>
</section>
<section id="http-outbound">