This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.18.x by this push:
     new 0acde894196e CAMEL-23046: camel-mail - If configured a 
IdempotentRepository then it should be auto started
0acde894196e is described below

commit 0acde894196eac00fab2426f9a59878e3e86c861
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Feb 23 19:19:58 2026 +0100

    CAMEL-23046: camel-mail - If configured a IdempotentRepository then it 
should be auto started
---
 .../org/apache/camel/component/mail/MailEndpoint.java  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git 
a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
 
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
index 6976c9de847a..c178fe7350c7 100644
--- 
a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
+++ 
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
@@ -33,6 +33,7 @@ import org.apache.camel.spi.IdempotentRepository;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.ScheduledPollEndpoint;
+import org.apache.camel.support.service.ServiceHelper;
 import org.eclipse.angus.mail.imap.SortTerm;
 
 import static 
org.apache.camel.component.mail.MailConstants.MAIL_GENERATE_MISSING_ATTACHMENT_NAMES_NEVER;
@@ -163,6 +164,23 @@ public class MailEndpoint extends ScheduledPollEndpoint 
implements HeaderFilterS
         return exchange;
     }
 
+    @Override
+    protected void doStart() throws Exception {
+        // idempotent repository may be used by others, so add it as a service
+        // so its stopped when CamelContext stops
+        if (idempotentRepository != null) {
+            getCamelContext().addService(idempotentRepository, true);
+        }
+        ServiceHelper.startService(idempotentRepository);
+        super.doStart();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        ServiceHelper.stopService(idempotentRepository);
+    }
+
     // Properties
     // 
-------------------------------------------------------------------------
 

Reply via email to