[ 
https://issues.apache.org/jira/browse/JAMES-1440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13640213#comment-13640213
 ] 

Yin,Shiwu commented on JAMES-1440:
----------------------------------

hi, Eric
  I met the same issue. Using JavaMail API with IMPA protocol, But it consumed 
5s time to open INBOX mailbox that there are only 1000 mails in INBOX. I looked 
at the code and found some clues as follows:

org.apache.james.imap.processor.base.SelectedMailboxImpl

private void init() throws MailboxException {
       ...
        synchronized (this) {
            while(messages.hasNext()) {
                MessageResult mr = messages.next();
                applicableFlags.add(mr.getFlags());
                add(mr.getUid());
            }         
        ...
    }

In the loop, Invoking getFlags method will costs about 5ms every time. in 
AbstractJPAMessage class, I found userFlags is a lazy-load strategy, which is 
the root cause. 

org.apache.james.mailbox.jpa.mail.model.openjpa.AbstractJPAMessage

    @OneToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
    @OrderBy("id")
    @ElementJoinColumns({@ElementJoinColumn(name="MAILBOX_ID", 
referencedColumnName="MAILBOX_ID"),
    @ElementJoinColumn(name="MAIL_UID", referencedColumnName="MAIL_UID")})
    private List<JPAUserFlag> userFlags;
                
> Imap receive mail  when there are many mails
> --------------------------------------------
>
>                 Key: JAMES-1440
>                 URL: https://issues.apache.org/jira/browse/JAMES-1440
>             Project: James Server
>          Issue Type: Bug
>          Components: IMAPServer
>    Affects Versions: 3.0-beta4
>         Environment: linux
>            Reporter: james
>              Labels: IMAP, mail
>
> hi,all
>         i have received mail from james that there are 30 thousand mails in 
> inbox,using javamail api with imap protocol. But it consumed 22s time to open 
> inbox mailbox,just open, not get messages.Then i changed the protocol to 
> pop3,it only cost 40ms. Why? Do imap  not support good when lagre of mails?
>                                                                               
>                                                 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to