|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
IMAP IDLE and deleting a messageHi there!
I need some help with the usage of the IDLE command in JavaMail. As far as I have seen, I have to create for each observed folder a new thread. Okay, that is fine. But do I have to create for EACH listener an additional thread? Wouldn't that be a little counterproductive? Following scenario: I'm connecting to an IMAP server through JavaMail 1.4.1. Then I'm starting on a specific folder one thread to monitor it. The run() method of the thread looks like this: ... folder.addMessageChangedListener(new MyMessageChangedListener()); folder.addMessageCountListener(new MyMessageCountListener()); while (!stop) { try { folder.idle(); } catch (FolderClosedException e) { log.info("Leaving idle..."); } ... As you can see, I install 2 listeners in this thread. Now, when I try to delete a message (setting the 'deleted' flag and expunging afterwards the folder) I get only the 'messageChanged' event. This is, I think, because the IDLE state has to be exited and reentered and so I loose my 'messageRemoved' event. Am I right? Is there any possibility to get the second notification too? Can I install somewhere a queue where unprocessed notifications will be stored? Thanks for Your help. Sincerely, Wolfgang =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: IMAP IDLE and deleting a messageWolfgang Beikircher wrote:
> Hi there! > > I need some help with the usage of the IDLE command in JavaMail. As far > as I have seen, I have to create for each observed folder a new thread. > Okay, that is fine. But do I have to create for EACH listener an > additional thread? Wouldn't that be a little counterproductive? No, JavaMail creates a thread to call all the listeners. > Following scenario: I'm connecting to an IMAP server through JavaMail > 1.4.1. Then I'm starting on a specific folder one thread to monitor it. > The run() method of the thread looks like this: > > ... > folder.addMessageChangedListener(new MyMessageChangedListener()); > folder.addMessageCountListener(new MyMessageCountListener()); > > while (!stop) { > try { > folder.idle(); > } catch (FolderClosedException e) { > log.info("Leaving idle..."); > } > ... > > As you can see, I install 2 listeners in this thread. Now, when I try to > delete a message (setting the 'deleted' flag and expunging afterwards > the folder) I get only the 'messageChanged' event. This is, I think, > because the IDLE state has to be exited and reentered and so I loose my > 'messageRemoved' event. Am I right? > > Is there any possibility to get the second notification too? Can I > install somewhere a queue where unprocessed notifications will be > stored? I believe you should get the message removed event when you call expunge. Is the expunge being done in the same application that's calling idle()? Can you send me the protocol trace when this occurs? You might also try the JavaMail 1.4.2 snapshot release, where some of this code has changed. (Search the archives for this list for a pointer.) =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: IMAP IDLE and deleting a messageOn Thu, 2009-02-12 at 10:35 -0800, Bill Shannon wrote:
> Wolfgang Beikircher wrote: > > Hi there! > > > > I need some help with the usage of the IDLE command in JavaMail. As far > > as I have seen, I have to create for each observed folder a new thread. > > Okay, that is fine. But do I have to create for EACH listener an > > additional thread? Wouldn't that be a little counterproductive? > > No, JavaMail creates a thread to call all the listeners. > > > Following scenario: I'm connecting to an IMAP server through JavaMail > > 1.4.1. Then I'm starting on a specific folder one thread to monitor it. > > The run() method of the thread looks like this: > > > > ... > > folder.addMessageChangedListener(new MyMessageChangedListener()); > > folder.addMessageCountListener(new MyMessageCountListener()); > > > > while (!stop) { > > try { > > folder.idle(); > > } catch (FolderClosedException e) { > > log.info("Leaving idle..."); > > } > > ... > > > > As you can see, I install 2 listeners in this thread. Now, when I try to > > delete a message (setting the 'deleted' flag and expunging afterwards > > the folder) I get only the 'messageChanged' event. This is, I think, > > because the IDLE state has to be exited and reentered and so I loose my > > 'messageRemoved' event. Am I right? > > > > Is there any possibility to get the second notification too? Can I > > install somewhere a queue where unprocessed notifications will be > > stored? > > I believe you should get the message removed event when you call expunge. > Is the expunge being done in the same application that's calling idle()? > Can you send me the protocol trace when this occurs? Actually, I don't remove messages via the 'expunge' method. I mark them first as 'DELETED' and then I close the folder with the parameter 'true' (folder.close(true)). Maybe I will change it. No, the expunge is not in the same application. I have a main thread which creates for each folder an additional thread. These additional threads contain the idle() command. Actually, I can not reproduce the error from yesterday. I'm sorry. But since it seems to work now, I'm happy about it. > > You might also try the JavaMail 1.4.2 snapshot release, where some of this > code has changed. (Search the archives for this list for a pointer.) Since it works now, I wouldn't change it anymore. I will wait until the release version is out and try to use then that version. Thank you for the fast answer. It seems, the people from Sun are great. ;) > > =========================================================================== > To unsubscribe, send email to listserv@... and include in the body > of the message "signoff JAVAMAIL-INTEREST". For general help, send email to > listserv@... and include in the body of the message "help". =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
| Free embeddable forum powered by Nabble | Forum Help |