INT-1583 updated documentation
This commit is contained in:
@@ -1,50 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="applicationevent"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<title>Spring ApplicationEvent Support</title>
|
||||
|
||||
<para>
|
||||
Spring Integration provides support for inbound and outbound <classname>ApplicationEvents</classname>
|
||||
as defined by the underlying Spring Framework. For more information about the events and listeners,
|
||||
as defined by the underlying Spring Framework. For more information about Spring's support for events and listeners,
|
||||
refer to the <ulink url="http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#context-functionality-events">Spring Reference Manual</ulink>.
|
||||
</para>
|
||||
|
||||
<section id="applicationevent-inbound">
|
||||
<title>Receiving Spring ApplicationEvents</title>
|
||||
<para>
|
||||
To receive events and send them to a channel, simply define an instance of Spring Integration's
|
||||
<classname>ApplicationEventListeningMessageProducer</classname>. This class is an implementation of
|
||||
Spring's <interfacename>ApplicationListener</interfacename> interface. By default it will pass all
|
||||
received events as Spring Integration Messages. To limit based on the type of event, configure the
|
||||
list of event types that you want to receive with the 'eventTypes' property.
|
||||
</para>
|
||||
<para>
|
||||
For convenience namespace support was provided to configure <classname>ApplicationEventListeningMessageProducer</classname> via <emphasis>inbound-channel-adapter</emphasis>
|
||||
<programlisting language="xml"><![CDATA[<int-event:inbound-channel-adapter channel="eventChannel" event-types="example.FooEvent, example.BarEvent"/>
|
||||
<para>
|
||||
To receive events and send them to a channel, simply define an instance of Spring Integration's
|
||||
<classname>ApplicationEventListeningMessageProducer</classname>. This class is an implementation of
|
||||
Spring's <interfacename>ApplicationListener</interfacename> interface. By default it will pass all
|
||||
received events as Spring Integration Messages. To limit based on the type of event, configure the
|
||||
list of event types that you want to receive with the 'eventTypes' property. If a received event
|
||||
has a Message instance as its 'source', then that will be passed as-is. Otherwise, if a SpEL-based
|
||||
"payloadExpression" has been provided, that will be evaluated against the ApplicationEvent instance.
|
||||
If the event's source is not a Message instance and no "payloadExpression" has been provided, then
|
||||
the ApplicationEvent itself will be passed as the payload.
|
||||
</para>
|
||||
<para>
|
||||
For convenience namespace support is provided to configure an <classname>ApplicationEventListeningMessageProducer</classname>
|
||||
via the <emphasis>inbound-channel-adapter</emphasis> element.
|
||||
<programlisting language="xml"><![CDATA[<int-event:inbound-channel-adapter channel="eventChannel" event-types="example.FooEvent, example.BarEvent"/>
|
||||
|
||||
<int:publish-subscribe-channel id="eventChannel"/>]]></programlisting>
|
||||
In the above example, all Application Context events that match one of the types specified by the 'event-types' (optional) attribute will be
|
||||
delivered as Spring Integration Messages to 'eventChannel'.
|
||||
</para>
|
||||
|
||||
delivered as Spring Integration Messages to the Message Channel named 'eventChannel'.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="applicationevent-outbound">
|
||||
<title>Sending Spring ApplicationEvents</title>
|
||||
<para>
|
||||
To send Spring <classname>ApplicationEvents</classname>, create an instance of the
|
||||
<classname>ApplicationEventPublishingMessageHandler</classname> and register it within an endpoint.
|
||||
This implementation of the <interfacename>MessageHandler</interfacename> interface also implements
|
||||
Spring's <interfacename>ApplicationEventPublisherAware</interfacename> interface and thus acts as a
|
||||
bridge between Spring Integration Messages and <classname>ApplicationEvents</classname>.
|
||||
</para>
|
||||
<para>
|
||||
For convenience namespace support was provided to configure <classname>ApplicationEventPublishingMessageHandler</classname> via <emphasis>outbound-channel-adapter</emphasis> element
|
||||
<programlisting language="xml"><![CDATA[<int:channel id="eventChannel"/>
|
||||
<title>Sending Spring ApplicationEvents</title>
|
||||
<para>
|
||||
To send Spring <classname>ApplicationEvents</classname>, create an instance of the
|
||||
<classname>ApplicationEventPublishingMessageHandler</classname> and register it within an endpoint.
|
||||
This implementation of the <interfacename>MessageHandler</interfacename> interface also implements
|
||||
Spring's <interfacename>ApplicationEventPublisherAware</interfacename> interface and thus acts as a
|
||||
bridge between Spring Integration Messages and <classname>ApplicationEvents</classname>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For convenience namespace support is provided to configure an <classname>ApplicationEventPublishingMessageHandler</classname>
|
||||
via the <emphasis>outbound-channel-adapter</emphasis> element.
|
||||
<programlisting language="xml"><![CDATA[<int:channel id="eventChannel"/>
|
||||
|
||||
<int-event:outbound-channel-adapter channel="eventChannel"/>]]></programlisting>
|
||||
If you are using a PollableChannel (e.g., Queue), you can also provide <emphasis>poller</emphasis> as a sub-element of the <emphasis>outbound-channel-adapter</emphasis> element. You can also optionally provide a <emphasis>task-executor</emphasis> reference for that poller.
|
||||
<programlisting language="xml"><![CDATA[<int:channel id="eventChannel">
|
||||
If you are using a PollableChannel (e.g., Queue), you can also provide <emphasis>poller</emphasis> as a sub-element of the
|
||||
<emphasis>outbound-channel-adapter</emphasis> element. You can also optionally provide a <emphasis>task-executor</emphasis>
|
||||
reference for that poller. The following example demonstrates both.
|
||||
<programlisting language="xml"><![CDATA[<int:channel id="eventChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
@@ -54,8 +63,10 @@ If you are using a PollableChannel (e.g., Queue), you can also provide <emphasis
|
||||
|
||||
<task:executor id="executor" pool-size="5"/>]]></programlisting>
|
||||
|
||||
In the above example, all messages sent to the 'eventChannel' channel will be published as ApplicationEvents to any relevant ApplicationListeners within the Spring ApplicationContext. If the payload of the Message is an ApplicationEvent, it will be passed as-is. Otherwise the Message itself will be wrapped in a MessagingEvent instance.
|
||||
</para>
|
||||
In the above example, all messages sent to the 'eventChannel' channel will be published as ApplicationEvents to any relevant
|
||||
ApplicationListener instances that are registered within the same Spring ApplicationContext. If the payload of the Message is
|
||||
an ApplicationEvent, it will be passed as-is. Otherwise the Message itself will be wrapped in a MessagingEvent instance.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
</chapter>
|
||||
|
||||
Reference in New Issue
Block a user