1 Reply Latest reply on Nov 13, 2005 3:29 PM by Joachim Van der Auwera

    Caching client ejb connections

    Tim McGinnis Newbie

      I have been working with Jboss for 2 years now and I still feel like a beginner. So plesae forgive me if this is a stupid question.

      When writing a client that accesses an EJB is it good/bad practice to cache the Home interface received by a findByPrimaryKey() call?

      My concern is how much of a performance hit is it to execute that findByPrimaryKey() call each time? Wouldn't it be better to execute it once and then stick the result in a static variable for later re-use?

        • 1. Re: Caching client ejb connections
          Joachim Van der Auwera Expert

          You can cache home objects, but caching actual beans is probably problematic. This would be good if you are sure the bean is used very often. However, otherwise, it will probably cause exceptions. Depending on your settings the bean will first be passivated and later removed after not being used for a certain time. When you then try to access the bean (because of your cache), and jboss has already removed it, exceptions will occur. IIRC bean removal will occur after 20 minutes.

          Joachim