Spring integration ayone能否共享与邮件附件示例相同的DSL?
我第一次考虑使用SpringIntegration:SpringIntegration示例中的邮件附件示例是一个很好的开始,我今天以惊人的轻松扩展了自己的用途 然而,我更愿意在工作中使用DSL,但是在研究了DSL示例之后,我有些不知所措,因为它们非常复杂Spring integration ayone能否共享与邮件附件示例相同的DSL?,spring-integration,dsl,Spring Integration,Dsl,我第一次考虑使用SpringIntegration:SpringIntegration示例中的邮件附件示例是一个很好的开始,我今天以惊人的轻松扩展了自己的用途 然而,我更愿意在工作中使用DSL,但是在研究了DSL示例之后,我有些不知所措,因为它们非常复杂 如果有人能分享任何spring集成示例的DSL重新实现,或者提供一些关于如何重新实现邮件附件示例的提示,我将不胜感激。目前没有该示例的DSL版本,但也许一个好的起点是?我成功地使用Java1.7用DSL重新实现了它。以下是有趣的部分: @Bea
如果有人能分享任何spring集成示例的DSL重新实现,或者提供一些关于如何重新实现邮件附件示例的提示,我将不胜感激。目前没有该示例的DSL版本,但也许一个好的起点是?我成功地使用Java1.7用DSL重新实现了它。以下是有趣的部分:
@Bean
public IntegrationFlow polledEmails() {
return IntegrationFlows
.from(
Mail.imapInboundAdapter( "imaps://" + user + ":" + password + "@imap.gmail.com:" + imapPort + "/inbox" )
.javaMailProperties( javaMailProperties() )
.shouldDeleteMessages( true )
)
.channel( MessageChannels.direct( "incomingEmail") )
.get();
}
@Bean
public IntegrationFlow extractAttachments() {
return IntegrationFlows
.from( "incomingEmail" )
.transform( new EmailTransformer() , "transformit" )
.split( new EmailSplitter() , "splitIntoMessages" )
.channel( MessageChannels.direct( "attachments") )
.get();
}
@Bean
public IntegrationFlow writeAttachmentAsFile() {
return IntegrationFlows
.from( "attachments" )
// save attachment to file
.handle(
Files.outboundAdapter( "'target/out/' + headers.directory" )
.autoCreateDirectory( true ) )
.get();
}
@Bean(name = PollerMetadata.DEFAULT_POLLER)
public PollerMetadata poller() {
return Pollers.fixedDelay( 5000 ).get();
}
private Properties javaMailProperties() {
final Properties properties = new Properties();
properties.put( "mail.store.protocol" , "pop3" );
properties.put( "mail.debug" , "false" );
return properties;
}
我使用Java1.7Thank@gary成功地用DSL实现了它,我确实设法拼凑了一些东西。从现在起,我将参考这些测试。谢谢-如果您想为邮件示例贡献代码,请参阅。