21.2. Configuring Bean Pools
21.2.1. Bean Pools Copy linkLink copied to clipboard!
@org.jboss.ejb3.annotation.Pool annotation can be used on EJBs to identify the pool, which has to be used for that EJB. This annotation points to the name of that pool.
21.2.2. Create a Bean Pool Copy linkLink copied to clipboard!
Procedure 21.1. Create a bean pool using the Management Console
- Login to the Management Console. Refer to Section 3.3.2, “Log in to the Management Console”.
- Click on the tab at the top of the screen. Expand the menu and select . Select the tab.
- Click . The Add EJB3 Bean Pools dialog appears.
- Specify the required details, Name, Max Pool Size, Timeout value, and Timeout unit.
- Click button to finish.
Procedure 21.2. Create a bean pool using the CLI
- Launch the CLI tool and connect to your server. Refer to Section 3.4.4, “Connect to a Managed Server Instance Using the Management CLI”.
- Use the
addoperation with the following syntax./subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:add(max-pool-size=MAXSIZE, timeout=TIMEOUT, timeout-unit="UNIT")
/subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:add(max-pool-size=MAXSIZE, timeout=TIMEOUT, timeout-unit="UNIT")Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Replace BEANPOOLNAME with the required name for the bean pool.
- Replace MAXSIZE with the maximum size of the bean pool.
- Replace TIMEOUT
- Replace UNIT with the required time unit. Allowed values are:
NANOSECONDS,MICROSECONDS,MILLISECONDS,SECONDS,MINUTES,HOURS, andDAYS.
- Use the
read-resourceoperation to confirm the creation of the bean pool./subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:read-resource
/subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:read-resourceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 21.1. Create a Bean Pool using the CLI
[standalone@localhost:9999 /] /subsystem=ejb3/strict-max-bean-instance-pool=ACCTS_BEAN_POOL:add(max-pool-size=500, timeout=5000, timeout-unit="SECONDS")
{"outcome" => "success"}
[standalone@localhost:9999 /] /subsystem=ejb3/strict-max-bean-instance-pool=ACCTS_BEAN_POOL:add(max-pool-size=500, timeout=5000, timeout-unit="SECONDS")
{"outcome" => "success"}
Example 21.2. XML Configuration Sample
21.2.3. Remove a Bean Pool Copy linkLink copied to clipboard!
Prerequisites:
- The bean pool that you want to remove cannot be in use. Refer to Section 21.2.5, “Assign Bean Pools for Session and Message-Driven Beans” to ensure that it is not being used.
Procedure 21.3. Remove a bean pool using the Management Console
- Login to the Management Console. Refer to Section 3.3.2, “Log in to the Management Console”.
- Click on the tab at the top of the screen. Expand the menu and select . Select the tab.
- Select the bean pool to remove in the list.
- Click . The Remove Item dialog appears.
- Click to confirm.
Procedure 21.4. Remove a bean pool using the CLI
- Launch the CLI tool and connect to your server. Refer to Section 3.4.4, “Connect to a Managed Server Instance Using the Management CLI”.
- Use the
removeoperation with the following syntax./subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:remove
/subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:removeCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Replace BEANPOOLNAME with the required name for the bean pool.
Example 21.3. Removing a Bean Pool using the CLI
[standalone@localhost:9999 /] /subsystem=ejb3/strict-max-bean-instance-pool=ACCTS_BEAN_POOL:remove
{"outcome" => "success"}
[standalone@localhost:9999 /] /subsystem=ejb3/strict-max-bean-instance-pool=ACCTS_BEAN_POOL:remove
{"outcome" => "success"}
21.2.4. Edit a Bean Pool Copy linkLink copied to clipboard!
Procedure 21.5. Edit a bean pool using the Management Console
- Login to the Management Console. Section 3.3.2, “Log in to the Management Console”
- Click on the tab at the top of the screen. Expand the menu and select . Select the tab.
- Select the bean pool you want to edit.
- Click .
- Edit the details you want to change. Only Max Pool Size, Timeout value, and Timeout Unit can be changed.
- Click to finish.
Procedure 21.6. Edit a bean pool using the CLI
- Launch the CLI tool and connect to your server. Refer to Section 3.4.4, “Connect to a Managed Server Instance Using the Management CLI”.
- Use the
write-attributeoperation with the following syntax for each attribute of the bean pool to be changed./subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:write-attribute(name="ATTRIBUTE", value="VALUE")
/subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:write-attribute(name="ATTRIBUTE", value="VALUE")Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Replace BEANPOOLNAME with the required name for the bean pool.
- Replace ATTRIBUTE with the name of the attribute to be edited. The attributes that can be edited in this way are
max-pool-size,timeout, andtimeout-unit. - Replace VALUE with the required value of the attribute.
- Use the
read-resourceoperation to confirm the changes to the bean pool./subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:read-resource
/subsystem=ejb3/strict-max-bean-instance-pool=BEANPOOLNAME:read-resourceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 21.4. Set the Timeout Value of a Bean Pool using the CLI
[standalone@localhost:9999 /] /subsystem=ejb3/strict-max-bean-instance-pool=HSBeanPool:write-attribute(name="timeout", value="1500")
{"outcome" => "success"}
[standalone@localhost:9999 /] /subsystem=ejb3/strict-max-bean-instance-pool=HSBeanPool:write-attribute(name="timeout", value="1500")
{"outcome" => "success"}
21.2.5. Assign Bean Pools for Session and Message-Driven Beans Copy linkLink copied to clipboard!
slsb-strict-max-pool and mdb-strict-max-pool for stateless session beans and message-driven beans respectively.
@Pool annotation can be used on EJBs to identify the pool to be used for that EJB.
Note
@Pool annotation on a particular EJB will override any default settings specified using the management interfaces.
Procedure 21.7. Assign Bean Pools for Session and Message-Driven Beans using the Management Console
- Login to the Management Console. Section 3.3.2, “Log in to the Management Console”
- Click on the tab at the top of the screen. Expand the menu and select . Select the tab.
- Click .
- Select the bean pool to use for each type of bean from the appropriate combo-box.
- Click to finish.
Procedure 21.8. Assign Bean Pools for Session and Message-Driven Beans using the CLI
- Launch the CLI tool and connect to your server. Refer to Section 3.4.4, “Connect to a Managed Server Instance Using the Management CLI”.
- Use the
write-attributeoperation with the following syntax./subsystem=ejb3:write-attribute(name="BEANTYPE", value="BEANPOOL")
/subsystem=ejb3:write-attribute(name="BEANTYPE", value="BEANPOOL")Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Replace BEANTYPE with
default-mdb-instance-poolfor Message-Driven Beans ordefault-slsb-instance-poolfor stateless session beans. - Replace BEANPOOL with the name of the bean pool to assign.
- Use the
read-resourceoperation to confirm the changes./subsystem=ejb3:read-resource
/subsystem=ejb3:read-resourceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 21.5. Assign a Bean Pool for Session Beans using the CLI
[standalone@localhost:9999 /] /subsystem=ejb3:write-attribute(name="default-slsb-instance-pool", value="LV_SLSB_POOL")
{"outcome" => "success"}
[standalone@localhost:9999 /] /subsystem=ejb3:write-attribute(name="default-slsb-instance-pool", value="LV_SLSB_POOL")
{"outcome" => "success"}
Example 21.6. XML Configuration Sample
Procedure 21.9. Assign a Bean Pool for a Session or Message-Driven Bean using the @Pool annotation
- Add the
@Poolannotation to the bean and specify the name of the bean pool to be used.This will override any default settings created in the management interfaces.@Stateless @Pool("slsb-strict-max-pool") public class HelloBean implements HelloBeanRemote {@Stateless @Pool("slsb-strict-max-pool") public class HelloBean implements HelloBeanRemote {Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
@org.jboss.ejb3.annotation.Poolannotation is part of the JBoss EJB3 External API and must be added as a dependency. If you are using Maven, the following dependency should be added to yourpom.xmlfile:<dependency> <groupId>org.jboss.ejb3</groupId> <artifactId>jboss-ejb3-ext-api</artifactId> <version>2.1.0</version> </dependency>
<dependency> <groupId>org.jboss.ejb3</groupId> <artifactId>jboss-ejb3-ext-api</artifactId> <version>2.1.0</version> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow