У меня есть работающая интеграция spring-mail (Spring boot application)
, и я могу проверить мой почтовый ящик Google.
По умолчанию я заметил, что он проверяет мой почтовый ящик каждые 2 минуты.
Я не могу вспомнить ни один код, который устанавливаетвремя, когда он проверяет мой почтовый ящик.
Теперь у меня возникла проблема, поскольку бывают случаи (хотя редко), когда мое приложение не может прочитать из папки входящих сообщений.
Я просто получаю это в своем журнале attempting to receive mail from folder [INBOX]
Что яЧтобы устранить проблему, перезапустите сервер tomcat, и теперь мое приложение сможет снова проверить свою электронную почту.
Журналы (с датой и временем):
2018-10-16 12:37:13 - attempting to receive mail from folder [INBOX]
2018-10-16 12:39:18 - attempting to receive mail from folder [INBOX]
2018-10-16 12:41:22 - attempting to receive mail from folder [INBOX]
2018-10-16 12:43:26 - attempting to receive mail from folder [INBOX]
2018-10-16 12:45:30 - attempting to receive mail from folder [INBOX]
2018-10-16 12:47:35 - attempting to receive mail from folder [INBOX]
2018-10-16 12:49:39 - attempting to receive mail from folder [INBOX]
2018-10-16 12:51:43 - attempting to receive mail from folder [INBOX]
2018-10-16 12:53:47 - attempting to receive mail from folder [INBOX]
2018-10-16 12:55:52 - attempting to receive mail from folder [INBOX]
2018-10-16 12:57:56 - attempting to receive mail from folder [INBOX]
2018-10-16 13:00:00 - attempting to receive mail from folder [INBOX]
2018-10-16 13:02:04 - attempting to receive mail from folder [INBOX]
2018-10-16 13:04:09 - attempting to receive mail from folder [INBOX]
2018-10-16 13:06:13 - attempting to receive mail from folder [INBOX]
2018-10-16 13:08:17 - attempting to receive mail from folder [INBOX]
2018-10-16 13:10:21 - attempting to receive mail from folder [INBOX]
2018-10-16 13:12:25 - attempting to receive mail from folder [INBOX]
2018-10-16 13:14:29 - attempting to receive mail from folder [INBOX]
2018-10-16 13:16:33 - attempting to receive mail from folder [INBOX]
2018-10-16 13:18:37 - attempting to receive mail from folder [INBOX]
2018-10-16 13:20:41 - attempting to receive mail from folder [INBOX]
2018-10-16 13:22:44 - attempting to receive mail from folder [INBOX]
2018-10-16 13:24:48 - attempting to receive mail from folder [INBOX]
2018-10-16 13:26:53 - attempting to receive mail from folder [INBOX]
2018-10-16 13:28:57 - attempting to receive mail from folder [INBOX]
2018-10-16 13:31:02 - attempting to receive mail from folder [INBOX]
2018-10-16 13:33:06 - attempting to receive mail from folder [INBOX]
2018-10-16 13:35:10 - attempting to receive mail from folder [INBOX]
2018-10-16 13:37:14 - attempting to receive mail from folder [INBOX]
2018-10-16 13:39:17 - attempting to receive mail from folder [INBOX]
2018-10-16 13:41:21 - attempting to receive mail from folder [INBOX]
2018-10-16 13:43:25 - attempting to receive mail from folder [INBOX]
2018-10-16 13:45:30 - attempting to receive mail from folder [INBOX]
2018-10-16 13:47:33 - attempting to receive mail from folder [INBOX]
2018-10-16 13:49:38 - attempting to receive mail from folder [INBOX]
Вопрос:
1. Как изменить время проверки входящей почты?
2. Это две (2) минуты или меньше - плохая идея?Я думаю, что Google может запретить ip доступ / проверку входящих сообщений.
Зависимость:
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mail</artifactId>
</dependency>
Mail Configuration:
@Configuration
public class MailConfig {
...
@Bean
@SuppressWarnings("Duplicates")
@Qualifier(value = "javaMailSender")
public JavaMailSender getJavaMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(m_mailHost);
mailSender.setPort(m_mailPort);
mailSender.setUsername(m_mailUserEmail);
mailSender.setPassword(m_mailPassword);
Properties props = mailSender.getJavaMailProperties();
props.put(PROPERTY_MAIL_TRANSPORT_PROTOCOL, m_mailProtocol);
props.put(PROPERTY_MAIL_SMTP_AUTHENTICATION, m_mailSmtpAuth);
props.put(PROPERTY_MAIL_SMTP_START_TLS_ENABLED, m_mailSmtpStartTlsEnabled);
props.put(PROPERTY_MAIL_DEBUG, m_mailDebug);
return mailSender;
}
@Bean
@Qualifier(value = "imapMailFlow")
public IntegrationFlow imapMailFlow() throws UnsupportedEncodingException {
String user = URLEncoder.encode(mailUserEmail, ConstantUtil.CHARACTER_ENCODING);
return IntegrationFlows
.from(Mail.imapIdleAdapter("imaps://" + user + ":" + mailPassword + "@imap.gmail.com:993/inbox")
.javaMailProperties(p -> p.put("mail.debug", "false")
.put("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory")
.put("mail.imap.socketFactory.fallback", "false").put("mail.store.protocol", "imaps"))
.shouldMarkMessagesAsRead(true).shouldDeleteMessages(false))
.channel("receiveChannel").get();
}
...
}
Было бы здорово, если бы вы могли дать ссылку с объяснениями.
Спасибо!