Red Hat Training
A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform
21.3. Configuring EJB Thread Pools
21.3.1. Enterprise Bean Thread Pools
JBoss EAP 6 maintains number of instances of Java thread objects in memory for use by enterprise bean services, including remote invocation, the timer service, and asynchronous invocation.
This technique is called thread pooling. It provides improved performance by eliminating the overhead of thread creation and gives the system administrator a mechanism for controlling resource usage.
Multiple thread pools can be created with different parameters and each service can be allocated a different thread pool.
21.3.2. Create a Thread Pool
EJB Thread pools can be created using the Management Console or the CLI.
Procedure 21.10. Create an EJB Thread Pool using the Management Console
- Login to the Management Console. Section 3.3.2, “Log in to the Management Console”
- Click on the Configuration tab at the top of the screen.
- Expand the Container menu and select EJB 3.
- Select the Thread Pools tab and click Add.
- Specify the Name and Max Threads values.
- Click Save to finish.
Procedure 21.11. Create a Thread 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
add
operation with the following syntax./subsystem=ejb3/thread-pool=THREAD_POOL_NAME:add(max-threads=MAX_SIZE)
- Replace THREAD_POOL_NAME with the name of the thread pool.
- Replace MAX_SIZE with the maximum size of the thread pool.
- Use the
read-resource
operation to confirm the creation of the bean pool./subsystem=ejb3/thread-pool=THREAD_POOL_NAME:read-resource
Example 21.7. Create a Thread Pool using the CLI
[standalone@localhost:9999 /] /subsystem=ejb3/thread-pool=my-test-pool:add(max-threads=20) {"outcome" => "success"}
Example 21.8. XML Configuration Sample
<subsystem xmlns="urn:jboss:domain:ejb3:1.5"> ... <thread-pools> ... <thread-pool name="my-test-pool" max-threads="20"/> </thread-pools> ... </subsystem>
21.3.3. Remove a Thread Pool
Unused EJB thread pools can be removed using the Management Console.
Prerequisites
- The thread pool that you want to remove cannot be in use. Refer to the following tasks to ensure that the thread pool is not in use:
Procedure 21.12. Remove an EJB thread pool using the Management Console
- Login to the Management Console. Section 3.3.2, “Log in to the Management Console”.
- Click on the Configuration tab at the top of the screen. Expand the Container menu and select EJB 3. Select the Thread Pools tab.
- Select the thread pool to you want to remove.
- Click Remove. The Remove Item dialog appears.
- Click Confirm.
Procedure 21.13. Remove a thread 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
remove
operation with the following syntax./subsystem=ejb3/thread-pool=THREADPOOLNAME:remove
- Replace THREADPOOLNAME with the name of the thread pool.
Example 21.9. Removing a Thread Pool using the CLI
[standalone@localhost:9999 /] /subsystem=ejb3/thread-pool=ACCTS_THREADS:remove {"outcome" => "success"}
21.3.4. Edit a Thread Pool
JBoss Administrators can edit Thread Pools using the Management Console and the CLI.
Procedure 21.14. Edit a Thread Pool using the Management Console
- Login to the Management Console. Section 3.3.2, “Log in to the Management Console”.
- Click on the Configuration tab at the top of the screen. Expand the Container menu and select EJB 3. Select the Thread Pools tab.
- Select the thread pool you want to edit.
- Click Edit.
- Edit the details you want to change. Only the
Thread Factory
,Max Threads
,Keepalive Timeout
, andKeepalive Timeout Unit
values can be edited. - Click Save to finish.
Procedure 21.15. Edit a thread 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_attribute
operation with the following syntax for each attribute of the thread pool to be changed./subsystem=ejb3/thread-pool=THREADPOOLNAME:write-attribute(name="ATTRIBUTE", value="VALUE")
- Replace THREADPOOLNAME with the name of the thread pool.
- Replace ATTRIBUTE with the name of the attribute to be edited. The attributes that can be edited in this way are
keepalive-time
,max-threads
, andthread-factory
. - Replace VALUE with the required value of the attribute.
- Use the
read-resource
operation to confirm the changes to the thread pool./subsystem=ejb3/thread-pool=THREADPOOLNAME:read-resource
Important
When changing the value of the
keepalive-time
attribute with the CLI the required value is an object representation. It has the following syntax.
/subsystem=ejb3/thread-pool=THREADPOOLNAME:write-attribute(name="keepalive-time", value={"time" => "VALUE","unit" => "UNIT"}
Example 21.10. Set the Maxsize Value of a Thread Pool using the CLI
[standalone@localhost:9999 /] /subsystem=ejb3/thread-pool=HSThreads:write-attribute(name="max-threads", value="50") {"outcome" => "success"}
Example 21.11. Set the keepalive-time
Time Value of a Thread Pool using the CLI
[standalone@localhost:9999 /] /subsystem=ejb3/thread-pool=HSThreads:write-attribute(name="keepalive-time", value={"time"=>"150"}) {"outcome" => "success"}