Skip to content

GH-8577: Deprecate ImapIdleCA.sendingTaskExecutor #8589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -21,7 +21,6 @@
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledFuture;

import jakarta.mail.Folder;
Expand All @@ -33,6 +32,7 @@
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.integration.endpoint.MessageProducerSupport;
import org.springframework.integration.mail.event.MailIntegrationEvent;
import org.springframework.integration.transaction.IntegrationResourceHolder;
Expand Down Expand Up @@ -78,7 +78,7 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be

private boolean shouldReconnectAutomatically = true;

private Executor sendingTaskExecutor = Executors.newFixedThreadPool(1);
private Executor sendingTaskExecutor = new SyncTaskExecutor();

private boolean sendingTaskExecutorSet;

Expand Down Expand Up @@ -107,7 +107,10 @@ public void setAdviceChain(List<Advice> adviceChain) {
* Specify an {@link Executor} used to send messages received by the
* adapter.
* @param sendingTaskExecutor the sendingTaskExecutor to set
* @deprecated since 6.0.5 in favor of async hands-off downstream in the flow,
* e.g. {@link org.springframework.integration.channel.ExecutorChannel}.
*/
@Deprecated(since = "6.0.5", forRemoval = true)
public void setSendingTaskExecutor(Executor sendingTaskExecutor) {
Assert.notNull(sendingTaskExecutor, "'sendingTaskExecutor' must not be null");
this.sendingTaskExecutor = sendingTaskExecutor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-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.
Expand Down Expand Up @@ -352,8 +352,11 @@ public ImapIdleChannelAdapterSpec transactional() {
* Specify a task executor to be used to send messages to the downstream flow.
* @param sendingTaskExecutor the sendingTaskExecutor.
* @return the spec.
* @see ImapIdleChannelAdapter#setSendingTaskExecutor(Executor)
* @deprecated since 6.1 in favor of async hands-off downstream in the flow,
* e.g. {@link org.springframework.integration.channel.ExecutorChannel}.
*/
@Deprecated(since = "6.0.5", forRemoval = true)
@SuppressWarnings("removal")
public ImapIdleChannelAdapterSpec sendingTaskExecutor(Executor sendingTaskExecutor) {
this.target.setSendingTaskExecutor(sendingTaskExecutor);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@
<xsd:attribute name="task-executor" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Reference to a bean that implements
[DEPRECATED] Reference to a bean that implements
org.springframework.core.task.TaskExecutor which is used
to send Messages received by this adapter.
If not provided, the adapter uses a single-threaded executor.
Deprecated since 6.0.5 in favor of async hand-off downstream in the flow.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mail="http://www.springframework.org/schema/integration/mail"
xmlns:integration="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task
https://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util
Expand Down Expand Up @@ -78,8 +75,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>

Expand All @@ -95,8 +91,6 @@
<prop key="foo">bar</prop>
</util:properties>

<task:executor id="executor" pool-size="5"/>

<mail:imap-idle-channel-adapter
id="autoChannel"
store-uri="imap:foo"
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -194,7 +194,6 @@ public void transactionalAdapter() {
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();
}

Expand Down
2 changes: 2 additions & 0 deletions src/reference/asciidoc/mail.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ In this case, the only header populated is the mentioned above `IntegrationMessa
Starting with version 5.5.11, the folder is closed automatically after `AbstractMailReceiver.receive()` if no messages received or all of them are filtered out independently of the `autoCloseFolder` flag.
In this case there is nothing to produce downstream for possible logic around `IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE` header.

Starting with version 6.0.5, an `ImapIdleChannelAdapter.sendingTaskExecutor` option is deprecated in favor of an asynchronous message handling in downstream flow, e.g. via an `ExecutorChannel` as an output channel of this channel adapter.

[[mail-mapping]]
=== Inbound Mail Message Mapping

Expand Down