Announcement Announcement Module
No announcement yet.
Client EJB Access Performance Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Client EJB Access Performance

    I am converting a J2EE app - that makes heavy use of remote EJBs - to use Spring. I have it working (Use Spring Simple Session Bean Factory to access the remote EJBs) but the performance is pretty slow. I know the first time you create the initial context, do all the lookups and go through all the required class loading, it should take a while, but with Spring, it seems to take the same amount of time on every request.

    Has anyone else run into this? I've created tests that initialize several threads and each makes several requests. I changed the bean from singleton to non-singleton, that took me from 11 seconds to 8 seconds average per request. I expect this to be closer to 2 seconds. My old app used reflection as well but would cache the Homes and Initial Contexts (didn't hang on to the remotes, that would negate Weblogic's container mgmt abilities). Not sure how Spring handles caching/retrieving.

    Any advice is appreciated. It's not a network issue, I'm running the two different versions side by side on the same machine. Thanks.

  • #2
    So I looked in the Spring code... they are caching the Home Interface. But with one of my EJBs, I do something like getClientList, getClientID, then getClient... (doesn't matter, I have to make 3 calls to perform my business). The problem is, we do a ejb create and invoke each time.

    The design is:
    AbstractRemoteSlsbInvokerInterceptor has a method invoke which calls local Abstract method doInvoke().
    SimpleRemoteSlsbInvokerInterceptor implements doInvoke() which calls getSessionBeanInstance(), does the method, then does a releaseSessionBeanInstance().

    The way it's designed, it has to do everything at once. How would I overload some combination of these classes so that I could do something like beginTransaction... cache my bean instance, do all the invokes through the businessInterface, and then do an endTransaction that would release the bean instance?

    I don't see how it can be done with the current design. My client bean would have to know more than just the business interface in order to manage the multiple calls.

    Any ideas? A dumb idea coming to mind is to reuse the same bean if it's being called within a 3 second timeout or something, otherwise release and renew. But then we may hold an instance indefinately.... Slap on a timer that destroys the instance after xx seconds of no use... this isn't going anywhere. Need more brains. Thanks.


    • #3
      This is funky. Say I have two bean instances called ClientManager. They have a business interface that is set using the SimpleStatelessSessionFactory. So I can't change the factory to return one instance every 10 seconds or whatever because then several clients will all be wanting to share the one instance of the EJB.

      There is a huge problem here in my mind. The SimpleStatelessSession bean factory is performing two roles - the method proxy as well as the ejb factory. So I'm unable to control a scenario where I want each client to get their own ejb, and invoke several methods on it. Since all method invocations happen through this factory, each method invocation gets its own ejb instance.

      This is ugly. Still up for advice if anyone is out there.


      • #4
        The Javadoc for doInvoke() offers a possible solution to invoking multiple business method calls on a single instance, but I cannot see how to release the instance when all the calls have completed, perhaps someone else will have a suggestion.

        Alternatively, override getSessionBeanInstance and releaseSessionBeanInstance to change EJB instance creation, for example to hold a single shared EJB instance.

        I have a very similiar situation to you, a legacy swing app I have integrated with Spring using SimpleRemoteStatelessSessionProxyFactoryBean to call remote EJB's. Although I have not measured timing, it is clear from the responsiveness of the app that it is not taking 11 secs to do a small number of EJB calls. Are you quite sure about you Spring config? Have you turned on debug logging to see what Spring is really doing?



        • #5
          Yea, I also read the javadoc suggestions, but since the doInvoke is in the factory, any client that has a reference to the EJB will be calling this doInvoke. So, you may limit it to one ejb reference, but if you have several clients using this factory, they all will share that single instance, which is also bad.

          I haven't turned up the debugging, but I've stepped down pretty far into the Spring Code using eclipse with the Spring source attached instead of jar includes.

          I sent an email to the author of the code, hopefully he may provide some direction.


          • #6
            is there a solution for this issue? i was trying to find out a way for that.