Configuring Managed Scheduled Executor Services
Managed scheduled executor services are used by applications to execute submitted tasks asynchronously at specific times. Tasks are executed on threads that are started and managed by the container. The context of the container is propagated to the thread executing the task.
Jakarta Concurrency specifies that certain default resources be made available to applications, and defines specific JNDI names for these default resources. Payara Server makes these names available through the use of logical JNDI names, which map Jakarta EE JNDI names to specific Payara Server resources. For managed scheduled executor services, the mapping is as follows: java:comp/DefaultManagedScheduledExecutorService This Jakarta Concurrency standard name is mapped to the concurrent/__defaultManagedScheduledExecutorService resource.
|
Create a Managed Scheduled Executor Service
Managed Scheduled Executor Services can be created by using Admin Console or Asadmin commands.
To create a new Managed Scheduled Executor Service in the Admin Console, go to Resources → Concurrent Resources → Managed Scheduled Executor Services → New:
Alternatively, the create-managed-scheduled-executor-service
asadmin command can be used to create a managed scheduled executor service resource.
Because all JNDI names are in the java:comp/env
subcontext, when specifying the JNDI name of a managed scheduled executor service, use only the concurrent/name
format. For example, concurrent/ScheduledExecutor1
.
Creating a managed scheduled executor service resource is a dynamic event and typically does not require server restart. Applications can use a resource as soon as it is created. However, if an application tried to use a resource before it was created, and that resource is created later, the application or the server must be restarted. Otherwise, the application will not be able to locate the resource. |
Usage
asadmin> create-managed-scheduled-executor-service [--help] [--enabled={false|true}] [--contextinfoenabled={false|true}] [--contextinfo={Classloader|JNDI|Security|WorkArea}] [--threadpriority threadpriority] [--longrunningtasks={false|true}] [--hungafterseconds hungafterseconds] [--corepoolsize corepoolsize] [--keepaliveseconds keepaliveseconds] [--threadlifetimeseconds threadlifetimeseconds] [--taskqueuecapacity taskqueuecapacity] [--description description] [--property property] [--target target] jndi_name
- Aim
-
The
create-managed-scheduled-executor-service
asadmin command creates a managed executor service resource.
Command Options
Option | Type | Description | Default | Mandatory |
---|---|---|---|---|
|
Boolean |
Determines whether the resource is enabled at runtime. |
true |
No |
|
Boolean |
Determines whether container contexts are propagated to threads. If set to |
true |
No |
|
String |
Specifies individual container contexts to propagate to threads. Valid values are |
|
No |
|
Integer |
Specifies the priority to assign to created threads. |
5 |
No |
|
Boolean |
Specifies whether the resource should be used for long-running tasks. If set to true, long-running tasks are not reported as stuck. |
false |
No |
|
Integer |
Specifies the number of seconds that a task can execute before it is considered unresponsive. |
0 |
No |
|
Integer |
Specifies the number of threads to keep in a thread pool, even if they are idle. |
0 |
No |
|
Integer |
Specifies the number of seconds that threads can remain idle when the number of threads is greater than |
60 |
No |
|
Integer |
Specifies the number of seconds that threads can remain in a thread pool before being purged, regardless of whether the number of threads is greater than |
0 |
No |
|
Integer |
Specifies the number of submitted tasks that can be stored in the task queue awaiting execution. |
2147483647 |
No |
|
String |
Descriptive details about the resource. |
- |
No |
|
String |
Optional attribute name/value pairs for configuring the resource. |
- |
No |
|
String |
Specifies the target for which you are creating the resource. Valid targets are: server, domain, cluster_name, instance_name |
server |
No |
Example
asadmin> create-managed-scheduled-executor-service --description "Scheduled Executor example" concurrent/myScheduledExecutor
Managed scheduled executor service concurrent/myScheduledExecutor created successfully.
Command create-managed-scheduled-executor-service executed successfully.
Listing Managed Scheduled Executor Services
This example lists managed scheduled executor service resources on the default server instance, server
.
asadmin> list-managed-scheduled-executor-services
concurrent/__defaultManagedExecutorService
concurrent/ScheduledExecutor1
concurrent/ScheduledExecutor2
Command list-managed-scheduled-executor-services executed successfully.
Update a Managed Scheduled Executor Service
You can change all of the settings for an existing managed scheduled executor service resource except its JNDI name. Use the get
and set
asadmin commands to view and change the values of the managed scheduled executor service attributes.
When a resource is updated, the existing resource is shut down and recreated. If an application used the resource prior to the update, the application or the server must be restarted. |
-
View the attributes of a managed scheduled executor service by using the
get
asadmin command.
asadmin> get resources.managed-scheduled-executor-service.{resource-JNDI-name}.*
-
Set an attribute of the managed scheduled executor service by using the set asadmin command.
asadmin> set resources.managed-scheduled-executor-service.{resource-JNDI-name}.deployment-order=120
Delete a Managed Scheduled Executor Service
The delete-managed-scheduled-executor-service
asadmin command to delete an existing managed scheduled executor service. Deleting a managed scheduled executor service is a dynamic event and does not require server restart.
Before deleting a managed scheduled executor service resource, all associations to the resource must be removed.
Deleting a Managed scheduled Executor Service
This example deletes the managed scheduled executor service resource named concurrent/ScheduledExecutor1
.
asadmin> delete-managed-scheduled-executor-service concurrent/ScheduledExecutor1
Managed scheduled executor service concurrent/ScheduledExecutor1 deleted successfully.
Command delete-managed-scheduled-executor-service executed successfully.