Hi That would be expected as you then let seda process the mail message in another thread that is independent from the consumer thread, which is closing the mail connection. So convert the payload to something like string or byte[] or whatever you need before sending to seda.
Or better use direct instead of seda. Think again why you use seda and if it's really needed. Do you really need concurrent mail processing? On Fri, Sep 12, 2025 at 9:52 AM Amarnath Reddy <amar2...@gmail.com> wrote: > Hi, > > IIn the below route configurations I am reading the email from Gmail and > then directing to a Cmel bean using seda endpoint. I close the connection > on every poll as a best practice. > > While reading the email body in the bean 'imapPreProcessor' I get an > exception as below. Kindly help me. > > Exception: > Inside process Error handler with exception {} > org.apache.camel.StreamCacheException: Error during type conversion from > type: jakarta.mail.internet.MimeMultipart to the required type: > org.apache.camel.StreamCache with value > jakarta.mail.internet.MimeMultipart@533502fd due to > org.apache.camel.TypeConversionException: Error during type conversion from > type: jakarta.mail.internet.MimeMultipart to the required type: > org.apache.camel.StreamCache with value > jakarta.mail.internet.MimeMultipart@533502fd due to > jakarta.mail.FolderClosedException: jakarta.mail.FolderClosedException; > > > > from("imaps://" + IMAP_HOST + ":" + IMAP_PORT + "/" + IMAP_FOLDER + > "?accessToken=" + OAUTH_ACCESS_TOKEN + > "&oauth2.enabled=true" + // Enable OAuth2 authentication > "&disconnect=true" + > "&closeFolder=true" + > "&consumer.delay=5000" + // Check for new emails every 5 > seconds > .routeId(WSCommonConstants.IMAP_ROUTE_ID) > .autoStartup(true) > .choice() > .when(method(PatternValidator.class, "isValid")) > .to("seda:gotoalart") > .otherwise() > .to("seda:gotoabcd") > .end();// Closes primary choice block; > > > > from("seda:gotoabcd?concurrentConsumers="+commonabcdConsumers) > .routeId("emailProcessChain") > .autoStartup(true) > .process(emailValidationProcessor) > .choice() > .when(simple("${header.validatedUser} != null && ${header.action} == > null")) > .process(imapPreProcessor) // StreamCacheException is coming here > .otherwise() > .process(authenticationFailedProcessor) > .to("direct:gotothirdstep"); > > Regards, > Amarnath > -- Claus Ibsen