我有一个奇怪的例外,这个例外发生在生产环境中的一周之后,偶尔发生。到目前为止,一切都很好。
在我使用imap连接到MS Exchange服务器以读取电子邮件的代码中。这部分代码仍然正常工作。
一旦阅读了电子邮件,它就会存档在子文件夹中。这部分有时会发送异常。
例外是“无法创建新的商店连接”。
在此消息之后,我在跟踪中总是有以下异常:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at org.springframework.integration.mail.MailReceivingMessageSource.receive(MailReceivingMessageSource.java:117)
at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:144)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:192)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:55)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:149)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:298)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:292)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.mail.MessagingException: Unrecognized SSL message, plaintext connection?;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:726)
at javax.mail.Service.connect(Service.java:364)
at javax.mail.Service.connect(Service.java:245)
at javax.mail.Service.connect(Service.java:194)
at org.springframework.integration.mail.AbstractMailReceiver.connectStoreIfNecessary(AbstractMailReceiver.java:227)
at org.springframework.integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:238)
at org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:260)
at org.springframework.integration.mail.MailReceivingMessageSource.receive(MailReceivingMessageSource.java:103)
我觉得奇怪的是,只有当我连接到商店时才会发生这种情况。我仍然可以毫无问题地阅读电子邮件。
这段代码抛出异常:
public void saveMessage(MimeMessage message, String folderName) {
try {
Folder folder = message.getFolder();
folder.open(Folder.READ_WRITE);
// Mark the message as Delete in its folder
String messageId = message.getMessageID();
Message[] messages = folder.getMessages();
似乎是getFolder发送消息。
我无法理解的是,当我尝试访问商店时,为什么会出现SSL异常,而使用相同的uri则没有任何问题来阅读电子邮件。
我有以下配置:
<int:channel id="receiveChannel" datatype="javax.mail.internet.MimeMessage"/>
<int-mail:inbound-channel-adapter id="incomingEmailsAdapter"
store-uri="${inboundMail.storeUri}"
channel="receiveChannel"
should-delete-messages="false"
should-mark-messages-as-read="true"
auto-startup="${inboundMail.startup}"
java-mail-properties="javaMailInboundProperties">
<int:poller max-messages-per-poll="${inboundMail.nb.poll}" fixed-rate="${inboundMail.nb.rate}"/>
</int-mail:inbound-channel-adapter>
<util:properties id="javaMailInboundProperties">
<prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imaps.ssl.trust">*</prop>
<prop key="mail.imap.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.debug">${inboundMail.debug}</prop>
</util:properties>
<int:service-activator id="serviceActivator" input-channel="receiveChannel" ref="mailService" method="handleMail"/>
使用:
inboundMail.storeUri = imaps://未知:REDACTED@company.com:993 / inbox
为什么我可以用这个uri阅读电子邮件,我不能用同一个商店打开商店吗?
这个问题每天发生几次,因为一周。
知道它可能来自哪里?
由于
吉勒