Is it possible to contol the number of threads used by clients invoking EJBs in EAP 6/7?
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
- 7.0.x
Issue
- There are a lot of threads seen if a client use EJB invocations, the threads are named as below, is it possible to reduce it?
config-based-ejb-client-endpoint task-#
config-based-naming-client-endpoint task-#
Resolution
The thread pool is created for XNIO and the number of threads is controlled by org.xnio.Options.WORKER_TASK_MAX_THREADS.
For clients which are mostly not using multiple threads to invoke server side EJB's the number of threads can be reduced to 2 if there is no throughput.
It depends on the type of client configuration which suffix for the property need to be used.
Consider if the client use both approaches both of the task threads are seen for the client java process!
EJBClientContext
This context can be configured by having
jboss-ejb-client.propertyfile for standalone java applications or application server from different vendorjboss-ejb-client.xmlfile if the application is inside of EAP and use remote-outbound connections- properties are used to create an EJBClientContext programatically
- properties to pass to InitialContext to create scoped-context
The threads are named config-based-ejb-client-endpoint task-# and the property
endpoint.create.options.org.xnio.Options.WORKER_TASK_MAX_THREADS
can by set to limit or increase the number of threads within the files or properties.
InitialContext for remote-naming
If the InitialContext include properties with the provider URL like remote:// or http-remoting:// the threads are named config-based-naming-client-endpoint task-# and the property which need to be added is
jboss.naming.client.endpoint.create.options.org.xnio.Options.WORKER_TASK_MAX_THREADS
Root Cause
By default there are some threads necessary to control the communication between client and server for EJB invocations.
In general there should be a READ and a WRITE thread which controlls the connection, in most of the use-cases there is no need to have more than the default of 1 each.
The task threads are used i.e. for retry or other side task.
Releated articles
How to configure an EJB client in JBoss EAP 6
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.