Menu

Multithreaded client example

2009-01-19
2013-06-03
  • Toelen Leen

    Toelen Leen - 2009-01-19

    Hi,

    I have some trouble writing a multithreaded program accessing a local (non-server) Lotus Notes database. I am getting memory lleaks that I guess are coming from the usage of Lotus Notes.

    What is the recommended way of using (and closing) the factory/session/database/views etc?

    Right now I am doing this (from multiple threads):

    Lock.lock()
    try{
    s = DNotesFactory.getInstance().getSession()
    d = s.getDatabase("",fileName)
    d.getAllDocuments();
    //iterate documents
    }
    {catch(){
    }finally{
    Lock.unlock()
    }

    Should I use factory.disposeInstance(true) somewhere or some other way to indicate that I am no longer using he a document?
    When I try to open the Lotus Notes client on tthe same machine, I always get an error that it is in use, this might be a side-effect from not closing everything correctly?

    Regards,
    Leen Toelen

     
    • Nobody/Anonymous

      You SHOULD use factory.disposeInstance(true)  to close and dispose all objects created from factory.

       
    • Toelen Leen

      Toelen Leen - 2009-01-21

      When i do so I get an exception

      de.bea.domingo.service.NotesServiceRuntimeException: Thread pool currently not running
          at de.bea.domingo.service.NotesServiceFactory.disposeInstance(NotesServiceFactory.java:294)

      Caused by: java.lang.IllegalStateException: Thread pool currently not running
          at de.bea.domingo.threadpool.SimpleThreadPool.invokeLater(SimpleThreadPool.java:291)
          at de.bea.domingo.service.NotesServiceFactory.invoke(NotesServiceFactory.java:359)
          at de.bea.domingo.service.NotesServiceFactory.disposeInstance(NotesServiceFactory.java:290)

      This is a standalone client connecting to a local notes database. According to the documentationthis is how I should use the factory. I am not sure how to use the NotesThread however.

       
    • Moody Ki

      Moody Ki - 2009-01-23

      According to the JavaDoc - DNotesFactory:

      It should be used DNotesFactory.dispose() to disposes the singleton instance of the factory.

      It is strictly recommended to call this method before exiting applications in order to not destabilize the Lotus Notes Client.

      If a factory was created with a newInstance(String, DNotesMonitor) method, the factory must be disposed with the instance method disposeInstance(boolean).

       

Log in to post a comment.