
Chapter 8 Creating J2EE Applications for BEA WebLogic
Using max-beans-in-free-pool
In general, you should not set the max-beans-in-free-pool element. When you ask the free pool for a bean instance, there are three possible situations that you can encounter. They are as follows:
- Option 1: An instance is available in the pool. You are given that instance and can proceed with processing.
- Option 2: No instance is available in the pool, but the number of instances in use is under max-beans-in-free-pool. In this case, WebLogic Server allocates a new bean instance and gives it to you.
- Option 3: No instances are available in the pool and the number of instances in use is already max-beans-in-free-pool. In this case, you sleep until either your transaction times out or a bean instance becomes available.
By default, max-beans-in-free-pool is the Int.max. That does not mean that you will be able to use 2 billion instances. Essentially, it means that Option 3 never happens. If a pooled instance does not exist, you will always just allocate a new one. In reality, you are limited with the number of executable threads. In most cases, each thread will need, at most, a single bean instance.
The only reason to set max-beans-in-free-pool is to limit access to an underlying resource. For example, if you use stateless session EJBs to implement a legacy connection pool, you do not want to allocate more bean instances than the number of connections that can be supported by your legacy system.
Special Use of max-beans-in-free pool
The following options describe special cases when max-beans-in-free-pool can be set to 0:
- Entity Beans: Never pool instances for entity beans. Instead, always allow a new instance to be created.
- Stateless Session Beans: Always create a new instance for stateless session beans.
- Stateful Session Beans: Not applicable for stateful session beans. These beans are not pooled.
- Message-Driven Beans: Illegal instances of message-driven beans are created and registered as JMS listeners during deployment. WebLogic Server never creates new instances at runtime. So, this value must be set to > 0.
|
Copyright (C) 2005. Sybase Inc. All rights reserved.
|
|