asadmin> create-context-service concurrent/Context1
Context service concurrent/Context1 created successfully.
Command create-context-service executed successfully.
Administering Concurrent Resources |
Previous | Next | Contents |
This chapter provides procedures for administering concurrent resources
in the GlassFish Server environment by using the asadmin
command-line
utility.
The following topics are addressed here:
Instructions for accomplishing these tasks by using the Administration Console are contained in the Administration Console online help.
Concurrent resources are managed objects that provide concurrency capabilities to Java EE applications. In GlassFish Server, you configure concurrent resources and make them available for use by application components such as servlets and EJBs. Concurrent resources are accessed through JNDI lookup or resource injection.
Concurrent resources are resources of the following types:
Context services. See Configuring Context Services.
Managed thread factories. See Configuring Managed Thread Factories.
Managed executor services. See Configuring Managed Executor Services.
Managed scheduled executor services. See Configuring Managed Scheduled Executor Services.
For detailed information about concurrent resources, see
"https://javaee.github.io/tutorial/concurrency-utilities.html[Concurrency
Utilities]" in The Java EE 8 Tutorial. Also see
Java Specification Request 236:
Concurrency Utilities for Java EE
(http://jcp.org/en/jsr/detail?id=236
).
When you create a concurrent resource, you specify a unique JNDI name for the resource. Applications use this name to access the resource.
The Java EE standard specifies that certain default resources be made available to applications, and defines specific JNDI names for these default resources. GlassFish Server makes these names available through the use of logical JNDI names, which map Java EE standard JNDI names to specific GlassFish Server resources. For concurrent resources, the mappings are as follows:
This Java EE standard name is mapped to the
concurrent/__defaultContextService
resource.
This Java EE standard name is mapped to the
concurrent/__defaultManagedThreadFactory
resource.
This Java EE standard name is mapped to the
concurrent/__defaultManagedExecutorService
resource.
This Java EE standard name is mapped to the
concurrent/__defaultManagedScheduledExecutorService
resource.
Context services are used to create dynamic proxy objects that capture the context of a container and enable applications to run within that context at a later time. The context of the container is propagated to the thread executing the task.
The following tasks are used to administer context service resources:
Use the create-context-service
subcommand in remote mode to create a
context service resource.
Because all JNDI names are in the java:comp/env
subcontext, when
specifying the JNDI name of a context service, use only the
concurrent/`name format. For example, `concurrent/Context1
.
For more information about the default context service resource included with GlassFish Server, see Default Concurrent Resources.
Note
|
Creating a context 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. |
Ensure that the server is running.
Remote subcommands require a running server.
Create a context service by using the
create-context-service
subcommand.
If necessary, notify users that the new resource has been created.
Example 14-1 Creating a Context Service
This example creates a context service resource named
concurrent/Context1
.
asadmin> create-context-service concurrent/Context1
Context service concurrent/Context1 created successfully.
Command create-context-service executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help create-context-service
at the command line.
Use the list-context-services
subcommand in remote mode to list the
existing context service resources.
Ensure that the server is running.
Remote subcommands require a running server.
List context service resources by using the
list-context-services
subcommand.
Example 14-2 Listing Context Services
This example lists context service resources on the default server
instance, server
.
asadmin> list-context-services
concurrent/__defaultContextService
concurrent/Context1
concurrent/Context2
Command list-context-services executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help list-context-services
at the command line.
You can change all of the settings for an existing context service
resource except its JNDI name. Use the get
and set
subcommands to
view and change the values of the context service attributes.
Note
|
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. |
Ensure that the server is running.
Remote subcommands require a running server.
List the context service resources by using the
list-context-services
subcommand.
View the attributes of a specific context service by using the get
subcommand.
For example:
asdmin> get resources.context-service.concurrent/Context1.*
Set an attribute of the context service by using the set
subcommand.
For example:
asdmin> set resources.context-service.concurrent/Context1.deployment-order=120
Use the delete-context-service
subcommand in remote mode to delete an
existing context service. Deleting a context service is a dynamic event
and does not require server restart.
Before deleting a context service resource, all associations to the resource must be removed.
Ensure that the server is running.
Remote subcommands require a running server.
List the context service resources by using the
list-context-services
subcommand.
If necessary, notify users that the context service is being deleted.
Delete the context service by using the
delete-context-service
subcommand.
Example 14-3 Deleting a Context Service
This example deletes the context service resource named
concurrent/Context1
.
asadmin> delete-context-service concurrent/Context1
Context service concurrent/Context1 deleted successfully.
Command delete-context-service executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help delete-context-service
at the command line.
Managed thread factories are used by applications to create managed threads on demand. The threads are started and managed by the container. The context of the container is propagated to the thread executing the task.
The following tasks are used to administer managed thread factory resources:
Use the create-managed-thread-factory
subcommand in remote mode to
create a managed thread factory resource.
Because all JNDI names are in the java:comp/env
subcontext, when
specifying the JNDI name of a managed thread factory, use only the
concurrent/`name format. For example, `concurrent/Factory1
.
For more information about the default managed thread factory resource included with GlassFish Server, see Default Concurrent Resources.
Note
|
Creating a managed thread factory 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. |
Ensure that the server is running.
Remote subcommands require a running server.
Create a managed thread factory by using the
create-managed-thread-factory
subcommand.
If necessary, notify users that the new resource has been created.
Example 14-4 Creating a Managed Thread Factory
This example creates a managed thread factory resource named
concurrent/Factory1
.
asadmin> create-managed-thread-factory concurrent/Factory1
Managed thread factory concurrent/Factory1 created successfully.
Command create-managed-thread-factory executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help create-managed-thread-factory
at the command line.
Use the list-managed-thread-factories
subcommand in remote mode to
list the existing managed thread factory resources.
Ensure that the server is running.
Remote subcommands require a running server.
List managed thread factory resources by using the
list-managed-thread-factories
subcommand.
Example 14-5 Listing Managed Thread Factories
This example lists managed thread factory resources on the default
server instance, server
.
asadmin> list-managed-thread-factories
concurrent/__defaultManagedThreadFactory
concurrent/Factory1
concurrent/Factory2
Command list-managed-thread-factories executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help list-managed-thread-factories
at the command line.
You can change all of the settings for an existing managed thread
factory resource except its JNDI name. Use the get
and set
subcommands to view and change the values of the managed thread factory
attributes.
Note
|
When a resource is updated, the existing resource is shut down and recreated. If applications used the resource prior to the update, the application or the server must be restarted. |
Ensure that the server is running.
Remote subcommands require a running server.
List the managed thread factory resources by using the
list-managed-thread-factories
subcommand.
View the attributes of a managed thread factory by using the get
subcommand.
For example:
asdmin> get resources.managed-thread-factory.concurrent/Factory1.*
Set an attribute of the managed thread factory by using the set
subcommand.
For example:
asdmin> set resources.managed-thread-factory.concurrent/Factory1.deployment-order=120
Use the delete-managed-thread-factory
subcommand in remote mode to
delete an existing managed thread factory. Deleting a managed thread
factory is a dynamic event and does not require server restart.
Before deleting a managed thread factory resource, all associations to the resource must be removed.
Ensure that the server is running.
Remote subcommands require a running server.
List the managed thread factory resources by using the
list-managed-thread-factories
subcommand.
If necessary, notify users that the managed thread factory is being deleted.
Delete the managed thread factory by using the
delete-managed-thread-factory
subcommand.
Example 14-6 Deleting a Managed Thread Factory
This example deletes the managed thread factory resource named
concurrent/Factory1
.
asadmin> delete-managed-thread-factory concurrent/Factory1
Managed thread factory concurrent/Factory1 deleted successfully.
Command delete-managed-thread-factory executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help delete-managed-thread-factory
at the command line.
Managed executor services are used by applications to execute submitted tasks asynchronously. 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.
The following tasks are used to administer managed executor service resources:
Use the create-managed-executor-service
subcommand in remote mode to
create a managed executor service resource.
Because all JNDI names are in the java:comp/env
subcontext, when
specifying the JNDI name of a managed executor service, use only the
concurrent/`name format. For example, `concurrent/Executor1
.
For more information about the default managed executor service resource included with GlassFish Server, see Default Concurrent Resources.
Note
|
Creating a managed 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. |
Ensure that the server is running.
Remote subcommands require a running server.
Create a managed executor service by using the
create-managed-executor-service
subcommand.
If necessary, notify users that the new resource has been created.
Example 14-7 Creating a Managed Executor Service
This example creates a managed executor service resource named
concurrent/Executor1
.
asadmin> create-managed-executor-service concurrent/Executor1
Managed executor service concurrent/Executor1 created successfully.
Command create-managed-executor-service executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help create-managed-executor-service
at the command
line.
Use the list-managed-executor-services
subcommand in remote mode to
list the existing managed executor service resources.
Ensure that the server is running.
Remote subcommands require a running server.
List managed executor service resources by using the
list-managed-executor-services
subcommand.
Example 14-8 Listing Managed Executor Services
This example lists managed executor service resources on the default
server instance, server
.
asadmin> list-managed-executor-services
concurrent/__defaultManagedExecutorService
concurrent/Executor1
concurrent/Executor2
Command list-managed-executor-services executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help list-managed-executor-services
at the command
line.
You can change all of the settings for an existing managed executor
service resource except its JNDI name. Use the get
and set
subcommands to view and change the values of the managed executor
service attributes.
Note
|
When a resource is updated, the existing resource is shut down and recreated. If applications used the resource prior to the update, the application or the server must be restarted. |
Ensure that the server is running.
Remote subcommands require a running server.
List the managed executor service resources by using the
list-managed-executor-services
subcommand.
View the attributes of a managed executor service by using the get
subcommand.
For example:
asdmin> get resources.managed-executor-service.concurrent/Executor1.*
Set an attribute of the managed executor service by using the set
subcommand.
For example:
asdmin> set resources.managed-executor-service.concurrent/Executor1.deployment-order=120
Use the delete-managed-executor-service
subcommand in remote mode to
delete an existing managed executor service. Deleting a managed executor
service is a dynamic event and does not require server restart.
Before deleting a managed executor service resource, all associations to the resource must be removed.
Ensure that the server is running.
Remote subcommands require a running server.
List the managed executor service resources by using the
list-managed-executor-services
subcommand.
If necessary, notify users that the managed executor service is being deleted.
Delete the managed executor service by using the
delete-managed-executor-service
subcommand.
Example 14-9 Deleting a Managed Executor Service
This example deletes the managed executor service resource named
concurrent/Executor1
.
asadmin> delete-managed-executor-service concurrent/Executor1
Managed executor service concurrent/Executor1 deleted successfully.
Command delete-managed-executor-service executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help delete-managed-executor-service
at the command
line.
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.
The following tasks are used to administer managed scheduled executor service resources:
Use the create-managed-scheduled-executor-service
subcommand in remote
mode 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
.
For more information about the default managed scheduled executor service resource included with GlassFish Server, see Default Concurrent Resources.
Note
|
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. |
Ensure that the server is running.
Remote subcommands require a running server.
Create a managed scheduled executor service by using the
create-managed-scheduled-executor-service
subcommand.
If necessary, notify users that the new resource has been created.
Example 14-10 Creating a Managed Scheduled Executor Service
This example creates a managed scheduled executor service resource named
concurrent/ScheduledExecutor1
.
asadmin> create-managed-scheduled-executor-service concurrent/ScheduledExecutor1
Managed scheduled executor service concurrent/ScheduledExecutor1 created successfully.
Command create-managed-scheduled-executor-service executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help create-managed-scheduled-executor-service
at the
command line.
Use the list-managed-scheduled-executor-services
subcommand in remote
mode to list the existing managed scheduled executor service resources.
Ensure that the server is running.
Remote subcommands require a running server.
List managed scheduled executor service resources by using the
list-managed-scheduled-executor-services
subcommand.
Example 14-11 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/__defaultManagedScheduledExecutorService
concurrent/ScheduledExecutor1
concurrent/ScheduledExecutor2
Command list-managed-scheduled-executor-services executed successfully.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help list-managed-scheduled-executor-services
at the
command line.
You can change all of the settings for an existing managed scheduled
executor service resource except its JNDI name. Use the get
and set
subcommands to view and change the values of the managed scheduled
executor service attributes.
Note
|
When a resource is updated, the existing resource is shut down and recreated. If applications used the resource prior to the update, the application or the server must be restarted. |
Ensure that the server is running.
Remote subcommands require a running server.
List the managed scheduled executor service resources by using the
list-managed-scheduled-executor-services
subcommand.
View the attributes of a managed scheduled executor service by using
the get
subcommand.
For example:
asdmin> get resources.managed-scheduled-executor-service.concurrent/ScheduledExecutor1.*
Set an attribute of the managed scheduled executor service by using
the set
subcommand.
For example:
asdmin> set resources.managed-scheduled-executor-service.concurrent/ScheduledExecutor1.deployment-order=120
Use the delete-managed-scheduled-executor-service
subcommand in remote
mode 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.
Ensure that the server is running.
Remote subcommands require a running server.
List the managed scheduled executor service resources by using the
list-managed-scheduled-executor-service
subcommand.
If necessary, notify users that the managed scheduled executor service is being deleted.
Delete the managed scheduled executor service by using the
delete-managed-scheduled-executor-service
subcommand.
Example 14-12 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.
See Also
You can also view the full syntax and options of the subcommand by
typing asadmin help delete-managed-scheduled-executor-service
at the
command line.
Previous | Next | Contents |