Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When does create actually create?

 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting more behavior I can't explain. This may or may not be related to the problem I posted here.
Thanks to wise advise from people here, I am using EJBs as follows....
  • In my ejbCreate, I use my service locator to get the home reference to any other EJBs this one might call in its methods.
  • In a particular method, when I need to use another session bean, I call fooHome.create() to get a reference to an actual EJB instance, and then [i]foo[i].remove() to remove it when I am done with it, freeing it up for others to use.


  • This seems to work well, and I have various beans calling each other. However, in one case, I have a timer thread. Every 10 seconds, this grabs the list of users, and calls a method in a session bean for each and every user (of which I currently have 106). I start the session beans with a pool of 4, max of 30. Speacificly, the timer thread calls one of its methods for each and every user, and that method calls the method on the EJB. What's happening is that I seem to be actually calling ejbCreate for 100 of the users, but not for the 6 others.
    This is bizzare! Why does it recycle beans for some users and not others?
    --Mark
     
    Chris Mathews
    Ranch Hand
    Posts: 2712
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Are we talking about Entity Beans or Session Beans? Or both?
    On Session Beans:
    Since the Container handles instance pooling and all that jazz the actual ejbCreate() call for Session Beans is handled by the Container. If there is a free instance available then that will be handed back instead of creating a new instance.
    On Entity Beans:
    I remember you saying that your application does not persist to a database... what happens if during heavy loads the EJB Container decides to swap out Bean Instances for your Entity Beans? What does your ejbStore() and ejbLoad() look like?
    [ March 11, 2003: Message edited by: Chris Mathews ]
     
    Mark Herschberg
    Sheriff
    Posts: 6037
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    In this case it's session beans...
    Originally posted by Chris Mathews:
    On Session Beans:
    Since the Container handles instance pooling and all that jazz the actual ejbCreate() call for Session Beans is handled by the Container. If there is a free instance available then that will be handed back instead of creating a new instance.

    That's what I thought. I can't imagine that it can't recycle these beans. I start with 4, max at 30. It calls ejbCreate 100 times! The operation doesn't take that long!

    Originally posted by Chris Mathews:
    On Entity Beans:
    I remember you saying that your application does not persist to a database... what happens if during heavy loads the EJB Container decides to swap out Bean Instances for your Entity Beans? What does your ejbStore() and ejbLoad() look like?

    Good point. I guess I could set a min greater then the number of users, but I've recently switched to a singleton hashtable. (Of course, I'm still not getting it to work.)
    --Mark
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!