camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Camel Guy <>
Subject Re: mail component: Stopping consumer when there are no more mails to read
Date Fri, 16 May 2014 15:40:17 GMT
Hello again,

I apologize for the two double-posts I sent recently. I sent the first ones
before the subscription link kicked in and figured they were lost forever.

Anyway, I implemented this feature for the mail component. I will
eventually submit a patch. This would be really easy but I have to change
the configuration class too.

Changes highlighted below.

BTW, I tried using consumer/producer templates. The fact that the consumer
operates in batch mode makes things pretty complicated at least with my
still primitive understanding of camel's APIs. We need a more advanced
book, like Camel in Action Part 2: Now You're Committed. I would actually
prefer to go the Polling Consumer route because I'm dynamically creating
new routes and stopping them (I'm reading many email accounts and the
credentials are stored in a database). This approach uses much CPU+memory
and seems to create a new thread each time I create a route (apparently not
materialized from thread pool since the thread ID keeps incrementing).

Thanks for watching,


           int count = folder.getMessageCount();

           if (count > 0) {


               polledMessages =

               getProcessor().process(getEndpoint().createExchange()); //

           } else if (count == -1) {

               throw new MessagingException("Folder: " + folder.getFullName()
+ " is closed");


           else { // New - there should be an if statement here to check
for sendEmptyMessageWhenIdle=true

                getProcessor().process(getEndpoint().createExchange()); //

           } // New

On Tue, May 13, 2014 at 9:20 PM, Camel Guy <> wrote:

> Hello,
> I'm using Camel 2.13.0 with the mail component (imaps:).
> I would like to know when all messages have been fetched from the server
> so I can stop polling.
> I tried using sendEmptyMessageWhenIdle=true but my route never sees a null
> body.
> Should I resort to a more manual PollingConsumer EIP approach?
> Thank you

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message