[英]How to reach previously read emails by using Spring Integration?
I am developing a dynamic and multiple IMAP channel listener application.我正在开发一个动态的多 IMAP 通道侦听器应用程序。 For the purpose of effectiveness, I am not downloading the attachments inside mails, just getting the texts inside them.为了效率起见,我不下载邮件里面的附件,只获取里面的正文。 Also I am developing an endpoint to access that previously arrived mails and download & return that attachment in order not to download every attachment.此外,我正在开发一个端点来访问以前到达的邮件并下载并返回该附件,以免下载每个附件。 So basically I am trying to download attachments only if there is a demand.所以基本上我只是在有需求时才尝试下载附件。
I am using ImapIdleChannelAdapter to listen mails inside integration flow.我正在使用 ImapIdleChannelAdapter 来收听集成流程中的邮件。 Here is my flow,这是我的流程,
public ImapIdleChannelAdapter mailAdapter(ImapMailReceiver receiver) {
ImapIdleChannelAdapter imapAdapter = new ImapIdleChannelAdapter(receiver);
imapAdapter.setAutoStartup(true);
return imapAdapter;
}
public IntegrationFlow createMailFlow(GmailRecieverRequirements requirements, String clientID) {
return IntegrationFlow.from(
mailAdapter(gmailMailReceiver(requirements)))
.handle(getMailHandler())
.get();
}
My question is, how can I access those previously read mails in different time?我的问题是,我怎样才能在不同的时间访问那些以前阅读过的邮件? I know Java Mail has Folder - UID structure to access mails via UIDs.我知道 Java 邮件具有文件夹 - UID 结构,可通过 UID 访问邮件。 Here is the link .这是链接。 However, I do not want to use javaMail inside my flow to save the UID.但是,我不想在流程中使用 javaMail 来保存 UID。 Is there any chance that I could reach UID of the mail inside the flow by Spring Integration?我是否有机会通过 Spring 集成获得流程内邮件的 UID? I am open to any other solution.我愿意接受任何其他解决方案。
Thanks in advance提前致谢
This is indeed low-level mail API functionality.这确实是低级邮件 API 的功能。 Not sure what you mean with your do not want to use javaMail inside my flow
, but we only can do that on demand fetching if we know the folder and message UID and with that respective API of the IMAPFolder
:不确定你do not want to use javaMail inside my flow
是什么意思,但如果我们知道文件夹和消息 UID 以及 IMAPFolder 的相应IMAPFolder
,我们只能按需获取:
/**
* Get the Message corresponding to the given UID. If no such
* message exists, <code>null</code> is returned.
*
* @param uid UID for the desired message
* @return the Message object. <code>null</code> is returned
* if no message corresponding to this UID is obtained.
* @exception MessagingException for failures
*/
public Message getMessageByUID(long uid) throws MessagingException;
The ImapIdleChannelAdapter
can produce raw jakarta.mail.Message
to let you to obtain its UID via UIDFolder.getUID(Message message)
API. ImapIdleChannelAdapter
可以生成原始的jakarta.mail.Message
以让您通过UIDFolder.getUID(Message message)
API 获取其 UID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.