INT-2867: Add Script Support to inbound-c-a
* Add `<script>` and `<expression>` to `<int:inbound-channel-adapter>` * Refactoring for `DefaultInboundChannelAdapterParser` * Introduce `ScriptExecutingMessageSource` to allow scripts' `MessageProcessor` implementations work as a source for polling endpoint JIRA: https://jira.springsource.org/browse/INT-2867 INT-2867: documentation In addition the tests for Lifecycle attributes Polishing
This commit is contained in:
committed by
Gary Russell
parent
63cbf736a2
commit
09be87551b
@@ -29,6 +29,9 @@
|
||||
<int:poller cron="30 * 9-17 * * MON-FRI"/>
|
||||
</int:channel-adapter>]]></programlisting>
|
||||
</para>
|
||||
<para>
|
||||
Also see <xref linkend="channel-adapter-expressions-and-scripts"/>.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
If no poller is provided, then a single default poller must be registered within the context.
|
||||
@@ -121,6 +124,9 @@
|
||||
of the <code><inbound-channel-adapter></code> or <code><outbound-channel-adapter></code> element. Therefore, if the "channel"
|
||||
is not provided, the "id" is required.
|
||||
</para>
|
||||
</section>
|
||||
<section id="channel-adapter-expressions-and-scripts">
|
||||
<title>Channel Adapter Expressions and Scripts</title>
|
||||
<para>
|
||||
Like many other Spring Integration components, the <code><inbound-channel-adapter></code> and
|
||||
<code><outbound-channel-adapter></code> also provide support for SpEL expression evaluation. To use SpEL, provide the
|
||||
@@ -130,6 +136,37 @@
|
||||
evaluation result is a <emphasis>non-null</emphasis> value, while the <emphasis>expression</emphasis> for an
|
||||
<code><outbound-channel-adapter></code> must be the equivalent of a <emphasis>void</emphasis> returning method invocation.
|
||||
</para>
|
||||
<para>
|
||||
Starting with Spring Integration 3.0, an <code><int:inbound-channel-adapter/></code> can also be configured
|
||||
with a SpEL <code><expression/></code> (or even with <code><script/></code>) sub-element, for when
|
||||
more sophistication is required than can be achieved with the simple 'expression' attribute.
|
||||
If you provide a script as a <interfacename>Resource</interfacename> using the <code>location</code>
|
||||
attribute, you can also set the <emphasis>refresh-check-delay</emphasis> allowing the resource to be refreshed
|
||||
periodically.
|
||||
If you want the script to be checked on each poll, you would need to coordinate this setting with the poller's trigger:
|
||||
</para>
|
||||
<programlisting language="xml"><![CDATA[<int:inbound-channel-adapter ref="source1" method="method1" channel="channel1">
|
||||
<int:poller max-messages-per-poll="1" fixed-delay="5000"/>
|
||||
<script:script lang="ruby" location="Foo.rb" refresh-check-delay="5000"/>
|
||||
</int:inbound-channel-adapter>]]></programlisting>
|
||||
<para>
|
||||
Also see the <code>cacheSeconds</code> property on the <classname>ReloadableResourceBundleExpressionSource</classname>
|
||||
when using the <code><expression/></code> sub-element.
|
||||
For more information regarding expressions see <xref linkend="spel"/>, and for scripts - <xref linkend="groovy"/>
|
||||
and <xref linkend="scripting"/>.
|
||||
</para>
|
||||
<important>
|
||||
<para>
|
||||
The <code><int:inbound-channel-adapter/></code> is an endpoint that starts a message flow
|
||||
via periodic triggering to poll some underlying <interfacename>MessageSource</interfacename>. Since, at the
|
||||
time of polling, there is not yet a message object, expressions and scripts don't
|
||||
have access to a root <classname>Message</classname>, so there are no <emphasis>payload</emphasis>
|
||||
or <emphasis>headers</emphasis> properties that are available in most other messaging SpEL expressions.
|
||||
Of course, the script <emphasis role="bold">can</emphasis>
|
||||
generate and return a complete <classname>Message</classname> object with headers and payload, or just
|
||||
a payload, which will be added to a message with basic headers.
|
||||
</para>
|
||||
</important>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
@@ -75,8 +75,15 @@
|
||||
<title>'Tail' Support</title>
|
||||
<para>
|
||||
File 'tail'ing inbound channel adapters are now provided to generate messages when
|
||||
lines are added to the end of text files.
|
||||
<xref linkend="file-tailing"/>.
|
||||
lines are added to the end of text files; see <xref linkend="file-tailing"/>.
|
||||
</para>
|
||||
</section>
|
||||
<section id="3.0-inbound-script">
|
||||
<title>Inbound Channel Adapter Script Support</title>
|
||||
<para>
|
||||
The <code><int:inbound-channel-adapter/></code> now supports <code><expression/></code>
|
||||
and <code><script/></code> sub-elements to create a
|
||||
<interfacename>MessageSource</interfacename>; see <xref linkend="channel-adapter-expressions-and-scripts"/>.
|
||||
</para>
|
||||
</section>
|
||||
<section id="3.0-spel-customization">
|
||||
|
||||
Reference in New Issue
Block a user