GH-8577: Revise ImapIdleChannelAdapter logic (#8588)
* GH-8577: Revise `ImapIdleChannelAdapter` logic Fixes https://github.com/spring-projects/spring-integration/issues/8577 When we process mail messages in async manner, it is possible that we end up in a race condition situation where the next idle cycle closes the folder. It is possible to reopen the folder, but feels better to block the current idle cycle until we are done with the message and therefore keep folder opened. * Deprecate `ImapIdleChannelAdapter.sendingTaskExecutor` in favor of an `ExecutorChannel` as an output for this channel adapter or similar async hand-off downstream. * Make use of `shouldReconnectAutomatically` as it is advertised for this channel adapter * Optimize the proxy creation for message sending task * * Remove `ImapIdleChannelAdapter.sendingTaskExecutor` * Fix language in docs Co-authored-by: Gary Russell <grussell@vmware.com> --------- Co-authored-by: Gary Russell <grussell@vmware.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -209,6 +209,7 @@ public class ImapMailReceiverTests {
|
||||
adapter.setOutputChannel(channel);
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
adapter.setReconnectDelay(1);
|
||||
adapter.afterPropertiesSet();
|
||||
adapter.start();
|
||||
MimeMessage message =
|
||||
GreenMailUtil.createTextEmail("Foo <foo@bar>", "Bar <bar@baz>", "Test Email", "foo\r\n",
|
||||
@@ -698,6 +699,7 @@ public class ImapMailReceiverTests {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
adapter.setOutputChannel(channel);
|
||||
adapter.setReconnectDelay(1);
|
||||
adapter.afterPropertiesSet();
|
||||
|
||||
ImapMailReceiver receiver = new ImapMailReceiver("imap:foo");
|
||||
receiver.setCancelIdleInterval(1);
|
||||
|
||||
@@ -78,8 +78,7 @@
|
||||
store-uri="imap:foo"
|
||||
channel="channel"
|
||||
auto-startup="false"
|
||||
should-delete-messages="true"
|
||||
task-executor="executor">
|
||||
should-delete-messages="true">
|
||||
<mail:transactional synchronization-factory="syncFactory" />
|
||||
</mail:imap-idle-channel-adapter>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -194,7 +194,6 @@ public class ImapIdleChannelAdapterParserTests {
|
||||
assertThat(receiverAccessor.getPropertyValue("shouldDeleteMessages")).isEqualTo(Boolean.TRUE);
|
||||
assertThat(receiverAccessor.getPropertyValue("shouldMarkMessagesAsRead")).isEqualTo(Boolean.TRUE);
|
||||
assertThat(adapterAccessor.getPropertyValue("errorChannel")).isNull();
|
||||
assertThat(adapterAccessor.getPropertyValue("sendingTaskExecutor")).isEqualTo(context.getBean("executor"));
|
||||
assertThat(adapterAccessor.getPropertyValue("adviceChain")).isNotNull();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user