use*_*545 2 java dsl spring spring-integration
我想通过Spring Integration接收邮件。我在xml配置中找到了很多示例,但在Java DSL配置中却找不到任何示例。如何使用Java DSL编写以下xml配置?
<int-mail:inbound-channel-adapter id="imapAdapter"
store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX"
channel="receiveChannel"
should-delete-messages="true">
<int:poller max-messages-per-poll="1" fixed-rate="5000"/>
</int-mail:inbound-channel-adapter>
Run Code Online (Sandbox Code Playgroud)
我尝试了以下解决方案,但我不知道如何向其中添加轮询器。
@Bean
public IntegrationFlow mailListener() {
return IntegrationFlows.from(Mail.imapInboundAdapter("imaps://[username]:[password]@imap.gmail.com/INBOX").shouldDeleteMessages(true).get())
.<Message>handle((payload, header) -> logMail(payload))
.get();
}
Run Code Online (Sandbox Code Playgroud)
请参阅DSL参考。
@Bean
public IntegrationFlow mailListener() {
return IntegrationFlows.from(Mail.imapInboundAdapter("imaps://[username]:[password]@imap.gmail.com/INBOX")
.shouldDeleteMessages(true).get(),
e -> e.poller(Pollers.fixedRate(5000).maxMessagesPerPoll(1)))
.<Message>handle((payload, header) -> logMail(payload))
.get();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2370 次 |
| 最近记录: |