The rule of thumb is roughly: - Use direct: for *synchronous, same-thread* communication. This should be the default in most cases. -
Use seda: for *asynchronous, in-memory, same-JVM* communication. - Use JMS/Artemis/Kafka/etc. for *distributed, persistent, cross-application* messaging. You can use seda when you want to decouple producers and consumers inside the same Camel application using an in-memory queue. Basically, seda allows one Camel route to hand work over to another route without blocking. The reason to do this is that you to want to make communication asynchronous, use buffering, or scaling (concurrency). In case there is not one of these reasons, you should use direct. Also note, that by default "direct" is the fastest and easiest way to connect routes to each other. Seda's performance has been improved in Camel 4, but you need a lot more tuning than direct to get maximum performance. Raymond On Mon, Sep 15, 2025 at 12:39 PM Amarnath Reddy <amar2...@gmail.com> wrote: > With SEDA we managed with convert the body to String. And its working fine > Do you foresee any issues with SEDA or let me know any exception mechanism > to take care of it.? > > Amarnadha > > On Mon, Sep 15, 2025 at 3:26 PM Claus Ibsen <claus.ib...@gmail.com> wrote: > > > 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 > > >