How many EJBObjects?

Discussions

EJB programming & troubleshooting: How many EJBObjects?

  1. How many EJBObjects? (5 messages)

    Hi,
      Can you guys expliain me how many EJBObjects will be created when there are n concurrent access to the EntityBean?Please give the detailed answer and if possible with respect to the specifications and the App servers
     regards
     Vicky

    Threaded Messages (5)

  2. How many EJBObjects?[ Go to top ]

    As many as the container wants to make, up to some pool limit you specify in the appserver config (this is app server dependent).

    If there are n threads trying to access the same entity (as defined by the same primary key) then users will have serial access to that bean.

    If there are n threads trying to access different entities, then the number of objects is unknown (since the container may reuse instances), but less than the pool limit.
  3. How many EJBObjects?[ Go to top ]

    Hi,
      Thanks!!
     What is the scope of the EJBObject?
    regards
    Vicky
  4. How many EJBObjects?[ Go to top ]

    Not sure what you mean by "scope."

    If you are asking how long the object will exist in memory after not being used, that should be a setting on your app server.
  5. How many EJBObjects?[ Go to top ]

    Hi,
      Yes you got my point.Can you give me example with respect to app server you use regarding the configuration?
    thanks and regards
    vicky
  6. How many EJBObjects?[ Go to top ]

    Your statement:
    "If there are n threads trying to access the same entity (as defined by the same primary key) then users will have serial access to that bean."
    is not exactly accurate. I am only speaking for Weblogic, I don't know how it goes with other containers. This is what we thought happens before until out production server died because of Out of Memory Error. When we looked into what's happening in our servers, we saw that for each access to the same entity bean, a separate instance is being created. And since our entity beans have relationships to so many other beans, more and more beans get created.

    For example, we have a Deal entity bean. This Deal has a 1-M relationship with say, Quotes, Contacts, Payments, Disbursements. So let's just get the Contacts. Out Contacts also has a 1-M relationship with Address. Each Address has a M-1 relationship with State and so forth and so on. Let's say our Deal has 10 Contacts. Each Contact has at least 2 Addresses. And each Address has 1 State which has 1 Country. When you get into the Deal screen you'll see that there are 1 deal + 10 contacts + 20 addresses + 20 states + 20 countries created. Another user comes in and choose the same Deal, the total count becomes doubled. And so forth and so on until some beans get passivated.

    I don't know if I explained it very well but what we saw was that for each read/write entity bean you create, even though their of the same PK, an instance will be created. So what we did was we implemented the Read-Mostly Pattern and that solved our problem a lot.

    J2EE Reigns!