Search code examples
javajboss7.xjava-ee-6ejb-3.1jboss-eap-6

Create Two Thread Pools for Asynchronous session bean methods in JBoss EAP6?


In my application I use @Asynchronous business methods on session beans in two different places. Each has its own logic and requirements so ideally I'd like to configure a maximum thread pool size for each. It looks like JBoss EAP 6.2.2 EAP only allows one asynchronous thread pool.

Is there a way to create two, or do I just have to create a single pool that will have enough for both (and lose the ability to limit either)?


Solution

  • I would expect that you have already looked at documentation on https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.2/pdf/Administration_and_Configuration_Guide/JBoss_Enterprise_Application_Platform-6.2-Administration_and_Configuration_Guide-en-US.pdf

    Extract from docs

    20.3. Configuring EJB Thread Pools 20.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.

    The above extract would seem to suggest that the following will provide 2 thread pools named first and second.

    <thread-pools>
       <thread-pool name="first" max-threads="20" keepalive-time="150"/>
       <thread-pool name="second" max-threads="20" keepalive-time="150"/>
    </thread-pools>