简体   繁体   中英

What is the appropriate way to trigger spring-integration int-mail:inbound-channel-adapter?

First of all to clarify: I'm new to spring-integration.

I want to receive mails via an pop3-channel. I know and (think so) understand the poller mechanics. But I also want to trigger the question for new mail by a client-event. Can this be done by a Gateway or an event or a special service-locator?

Thank you brave helpers!

Don't want to find similar solution, which I showed earlier, even on SO. But as you say that you are newbie, so I just provide the solution for you.

Well, supose you have something like this now:

<int-mail:inbound-channel-adapter store-uri="pop3:foo"
                              channel="channel">
      <int:poller fixed-rate="60000"/>
</int-mail:inbound-channel-adapter>

On the background that configuration provides a bean for Pop3MailReceiver . To get worked you solution you should change <int-mail:inbound-channel-adapter/> to this config:

<beans:bean id="pop3MailReceiver" class="org.springframework.integration.mail.Pop3MailReceiver"/>

<int:inbound-channel-adapter channel="getEmailsChannel" expression="''">
    <int:poller fixed-rate="60000"/>
</int:inbound-channel-adapter>

<int:service-activator input-channel="getEmailsChannel" output-channel="processEmailsChannel"
                               expression="@pop3MailReceiver.receive()"/>
  1. Of course, you should provide appropriate properties to the Pop3MailReceiver
  2. Generic <int:inbound-channel-adapter> triggers your Pop3MailReceiver as it is in your case already invoking <int:service-activator>
  3. <int:service-activator> , in turn, just poll mail messages from POP3.

One point to pay attention, that MailReceiver#receive() returns an array of mail messages, so maybe there is need to split it after receiving, to be consistent with <int-mail:inbound-channel-adapter/> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM