An "outbound-channel-adapter" element can also connect a MessageChannel
to any POJO consumer
method that should be invoked with the payload of Messages sent to that channel.
<outbound-channel-adapter channel="channel1" ref="target1" method="method1"/>
If the channel being adapted is a PollableChannel
, provide a poller sub-element:
<outbound-channel-adapter channel="channel2" ref="target2" method="method2"> <poller> <interval-trigger interval="3000"/> </poller> </outbound-channel-adapter> <beans:bean id="target1" class="org.bar.Foo"/>
Using a "ref" attribute is generally recommended if the POJO consumer implementation can be reused
in other <outbound-channel-adapter>
definitions. However if the consumer implementation
should be scoped to a single definition of the <outbound-channel-adapter>
, you can define it as inner bean:
<outbound-channel-adapter channel="channel2" method="method2"> <beans:bean class="org.bar.Foo"/> </outbound-channel-adapter>
Note | |
---|---|
Using both the "ref" attribute and an inner handler definition in the same |
Any Channel Adapter can be created without a "channel" reference in which case it will implicitly create an
instance of DirectChannel
. The created channel's name will match the "id" attribute
of the <inbound-channel-adapter/> or <outbound-channel-adapter element. Therefore, if the "channel"
is not provided, the "id" is required.