Discussion:
IMAP IDLE and deleting a message
Wolfgang Beikircher
16 years ago
Permalink
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?

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 ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".
Bill Shannon
16 years ago
Permalink
Post by Wolfgang Beikircher
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.
...
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 ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".
Wolfgang Beikircher
16 years ago
Permalink
...
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.
Post by Bill Shannon
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. ;)
Post by Bill Shannon
===========================================================================
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
===========================================================================
To unsubscribe, send email to ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".
Loading...