views:

52

answers:

1

I have this:

 <si:poller max-messages-per-poll="10" id="defaultPoller" default="true">
  <si:interval-trigger interval="5000"/>
 </si:poller>
 <si:channel id="emailIn"/>
 <si:channel id="emailOut"/>

 <si:service-activator input-channel="emailIn" output-channel="emailOut" ref="mailService" method="recieveMessage"/>

 <si:gateway id="gateway" service-interface="com.blah.MailSender" default-request-channel="emailIn"/>

 <si:outbound-channel-adapter channel="emailOut" ref="mailService" method="recieveMessage" />

And I thought what I was configuring was an async Queue. I want to be able to drop messages onto it, and have a nother thread pick them up and process then later. However, at the momment it seems to do it in a synchronous way.

Am i doing it wrong (obvioulsy yes), but wondering if there is something i'm missing in this config, or whether i just have the wrong approach?

Cheers

+1  A: 

By default all channels in Spring Integration are synchronous. This is a conscious design decision that will help you keep transaction boundaries and security contexts for example. When you want to do asynchronous hand-off you should add a task executor to your dispatcher or a queue to your channel:

<channel>
  <dispatcher task-executor="pool"/>
</channel>

<channel>
  <queue capacity="10"/>
</channel>

Look at channel configurations in the reference guide for some details on dispatchers and queues. See also the section on DirectChannel and the section on ExecutorChannel below that one.

iwein