/** * An {@link ImapIdleChannelAdapterSpec} factory based on the provided {@link ImapMailReceiver}. * @param imapMailReceiver the {@link ImapMailReceiver} to use. * @return the {@link ImapIdleChannelAdapterSpec} instance. * @since 1.2 */ public static ImapIdleChannelAdapterSpec imapIdleAdapter(ImapMailReceiver imapMailReceiver) { return new ImapIdleChannelAdapterSpec(imapMailReceiver, true); }
/** * Set the name of the flag to use to flag messages when the server does * not support \Recent but supports user flags; * default {@value ImapMailReceiver#DEFAULT_SI_USER_FLAG}. * @param userFlag the flag. * @return the spec. * @since 1.2 * @see ImapMailReceiver#setUserFlag(String) */ public ImapIdleChannelAdapterSpec userFlag(String userFlag) { assertReceiver(); this.receiver.setUserFlag(userFlag); return _this(); }
/** * @param javaMailProperties the javaMailProperties. * @return the spec. * @see ImapMailReceiver#setJavaMailProperties(Properties) */ public ImapIdleChannelAdapterSpec javaMailProperties(Properties javaMailProperties) { assertReceiver(); assertSession(); this.receiver.setJavaMailProperties(javaMailProperties); return this; }
@Bean public IntegrationFlow imapIdleFlow() { return IntegrationFlows .from(Mail.imapIdleAdapter("imap://user:pw@localhost:" + imapIdleServer.getPort() + "/INBOX") .autoStartup(true) .searchTermStrategy(this::fromAndNotSeenTerm) .userFlag("testSIUserFlag") .javaMailProperties(p -> p.put("mail.debug", "false") .put("mail.imap.connectionpoolsize", "5")) .shouldReconnectAutomatically(false) .headerMapper(mailHeaderMapper())) .channel(MessageChannels.queue("imapIdleChannel")) .get(); }
/** * @param shouldMarkMessagesAsRead the shouldMarkMessagesAsRead. * @return the spec. * @see ImapMailReceiver#setShouldMarkMessagesAsRead(Boolean) */ public ImapIdleChannelAdapterSpec shouldMarkMessagesAsRead(boolean shouldMarkMessagesAsRead) { assertReceiver(); this.receiver.setShouldMarkMessagesAsRead(shouldMarkMessagesAsRead); return this; }
/** * Configure the {@code javaMailProperties} by invoking a {@link Consumer} callback which * is invoked with a {@link PropertiesBuilder}. * @param configurer the configurer. * @return the spec. * @see ImapMailReceiver#setJavaMailProperties(Properties) */ public ImapIdleChannelAdapterSpec javaMailProperties(Consumer<PropertiesBuilder> configurer) { PropertiesBuilder properties = new PropertiesBuilder(); configurer.accept(properties); return javaMailProperties(properties.get()); }
/** * Configure a SpEL expression to select messages. The root object for the expression * evaluation is a {@link javax.mail.internet.MimeMessage} which should return a boolean * result (true means select the message). * @param selectorExpression the selectorExpression. * @return the spec. */ public ImapIdleChannelAdapterSpec selectorExpression(String selectorExpression) { return selectorExpression(PARSER.parseExpression(selectorExpression)); }
/** * A Java Mail {@link Session} to use. * @param session the session. * @return the spec. * @see ImapMailReceiver#setSession(Session) */ public ImapIdleChannelAdapterSpec session(Session session) { assertReceiver(); this.receiver.setSession(session); this.sessionProvided = true; return this; }
/** * Configure the {@code javaMailProperties} by invoking a {@link Consumer} callback which * is invoked with a {@link PropertiesBuilder}. * @param configurer the configurer. * @return the spec. * @see ImapMailReceiver#setJavaMailProperties(Properties) */ public ImapIdleChannelAdapterSpec javaMailProperties(Consumer<PropertiesBuilder> configurer) { PropertiesBuilder properties = new PropertiesBuilder(); configurer.accept(properties); return javaMailProperties(properties.get()); }
/** * Configure a {@link Function} to select messages. The argument for the function * is a {@link javax.mail.internet.MimeMessage}; {@code apply} returns a boolean * result (true means select the message). * @param selectorFunction the selectorFunction. * @return the spec. * @see FunctionExpression */ public ImapIdleChannelAdapterSpec selector(Function<MimeMessage, Boolean> selectorFunction) { return selectorExpression(new FunctionExpression<MimeMessage>(selectorFunction)); }
/** * Set the name of the flag to use to flag messages when the server does * not support \Recent but supports user flags; * default {@value ImapMailReceiver#DEFAULT_SI_USER_FLAG}. * @param userFlag the flag. * @return the spec. * @since 1.2 * @see ImapMailReceiver#setUserFlag(String) */ public ImapIdleChannelAdapterSpec userFlag(String userFlag) { assertReceiver(); this.receiver.setUserFlag(userFlag); return _this(); }
/** * @param javaMailAuthenticator the javaMailAuthenticator. * @return the spec. * @see ImapMailReceiver#setJavaMailAuthenticator(Authenticator) */ public ImapIdleChannelAdapterSpec javaMailAuthenticator(Authenticator javaMailAuthenticator) { assertReceiver(); assertSession(); this.receiver.setJavaMailAuthenticator(javaMailAuthenticator); return this; }
/** * @param maxFetchSize the maxFetchSize. * @return the spec. * @see ImapMailReceiver#setMaxFetchSize(int) */ public ImapIdleChannelAdapterSpec maxFetchSize(int maxFetchSize) { assertReceiver(); this.receiver.setMaxFetchSize(maxFetchSize); return this; }
/** * An {@link ImapIdleChannelAdapterSpec} factory based on the provided {@link ImapMailReceiver}. * @param imapMailReceiver the {@link ImapMailReceiver} to use. * @return the {@link ImapIdleChannelAdapterSpec} instance. * @since 1.2 */ public static ImapIdleChannelAdapterSpec imapIdleAdapter(ImapMailReceiver imapMailReceiver) { return new ImapIdleChannelAdapterSpec(imapMailReceiver, true); }
/** * Configure a SpEL expression to select messages. The root object for the expression * evaluation is a {@link javax.mail.internet.MimeMessage} which should return a boolean * result (true means select the message). * @param selectorExpression the selectorExpression. * @return the spec. */ public ImapIdleChannelAdapterSpec selectorExpression(String selectorExpression) { return selectorExpression(PARSER.parseExpression(selectorExpression)); }
/** * Set the header mapper; if a header mapper is not provided, the message payload is * a {@link MimeMessage}, when provided, the headers are mapped and the payload is * the {@link MimeMessage} content. * @param headerMapper the header mapper. * @return the spec. * @since 1.2 * @see ImapMailReceiver#setUserFlag(String) * @see #embeddedPartsAsBytes(boolean) */ public ImapIdleChannelAdapterSpec headerMapper(HeaderMapper<MimeMessage> headerMapper) { assertReceiver(); this.receiver.setHeaderMapper(headerMapper); return _this(); }
/** * @param javaMailAuthenticator the javaMailAuthenticator. * @return the spec. * @see ImapMailReceiver#setJavaMailAuthenticator(Authenticator) */ public ImapIdleChannelAdapterSpec javaMailAuthenticator(Authenticator javaMailAuthenticator) { assertReceiver(); assertSession(); this.receiver.setJavaMailAuthenticator(javaMailAuthenticator); return this; }
/** * @param shouldDeleteMessages the shouldDeleteMessages. * @return the spec. * @see ImapMailReceiver#setShouldDeleteMessages(boolean) */ public ImapIdleChannelAdapterSpec shouldDeleteMessages(boolean shouldDeleteMessages) { assertReceiver(); this.receiver.setShouldDeleteMessages(shouldDeleteMessages); return this; }
public static ImapIdleChannelAdapterSpec imapIdleAdapter(String url) { return new ImapIdleChannelAdapterSpec(new ImapMailReceiver(url)); }
/** * Configure a {@link Function} to select messages. The argument for the function * is a {@link javax.mail.internet.MimeMessage}; {@code apply} returns a boolean * result (true means select the message). * @param selectorFunction the selectorFunction. * @return the spec. * @see FunctionExpression */ public ImapIdleChannelAdapterSpec selector(Function<MimeMessage, Boolean> selectorFunction) { return selectorExpression(new FunctionExpression<MimeMessage>(selectorFunction)); }