Configuring ManagedExecutorService instances

You can configure ManagedExecutorService instances to run asynchronous tasks with the specified thread context. It is a best practice for Java™ EE applications to avoid directly managing their own threads; therefore, the ManagedExecutorService extends the JSE ExecutorService to provide a way to launch asynchronous tasks within an application server environment. You might also configure the ManagedExecutorService to propagate various thread contexts that are relevant to Java EE applications to the thread of the asynchronous task.

Fix Pack 8550

About this task

The ManagedExecutorService is available under the <concurrent-1.0> feature and enabled in the server.xml file as follows:
<featureManager>
	<feature>concurrent-1.0</feature>
</featureManager>

Propagation of context to the thread of a task that is executed by the ManagedExecutorService is managed by the context service. A default instance of the context service (DefaultContextService) is created by the server and configured to propagate at least classloaderContext, jeeMetadataContext and securityContext. This default context service instance is used if a ManagedExecutorService is created without referring to a specific context service instance or configuring a context service instance directly within. Refer to the Configuring thread context service instances topic for more information.

A default managed executor instance (DefaultManagedExecutorService) is available as java:comp/DefaultManagedExecutorService and uses the default context service instance for thread context capture and propagation.

Attention: A current limitation in the Alpha is that submitted tasks might not run until Future.get is invoked.

Procedure

Example configuration in the server.xml file:

Example

Managed executor serviced instances can be injected into application components (by using @Resource) or looked up with resource environment references (resource-env-ref). Regardless of how the instance is obtained, you can use it interchangeably as javax.enterprise.concurrent.ManagedExecutorService or its java.util.concurrent.ExecutorSerivce superclass.


Icon that indicates the type of topic Task topic

Terms and conditions for information centers | Feedback


Timestamp icon Last updated: Monday, 21 April 2014
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-nd-mp&topic=twlp_config_managedexecutor
File name: twlp_config_managedexecutor.html