Java Mail IMAP search taking lot of time when there are lot of messages in mail box.
posted 6 months ago
I have written a scheduler to run every one minute and use IMAP (SSL) API to get all unread messages and then mark only 200 messages from it as read and then read content of each message (200) one by one. Issue I am facing is when mail box is having around 400k messages (100GB) the first command to get unread messages itself taking more than 10 mins. I am not sure if this is how imap behaves or is it something slow at mailbox or network level. Eventually my target is to read around 500k emails in 24 hours from mail box where one message will be of around 250kb and then store each HTML message in oracle DB as blob. Currently I am no where near to achieve this target. I am attaching my code below. It is processing only 50 messages in a minute. I would really appreciate if some one can guide me to fix any performance issues in my code. Also if some has experience of extracting HTML email from mail box and persisting in database using any way, It would be really helpful if you can share your knowledge. Thanks!