Configure Work managers for one-way operations
We can configure Work managers for one-way operations. In the product, Work manager configuration is supported only at the component service level. This capability is supported for default and web services binding.
Asynchronous service dispatches run on a different thread than the service invoker. The thread pool that services these dispatches must be configurable so that the service thread pool can be adjusted, based on workload variations or some other policy. The application server has configurable thread pools, called Work managers, that can be used as the means for providing an asynchronous thread pool to an SCA service.
This topic applies to non-blocking (one-way) operations only. The Java composite definition (.composite file) for the component service that has the one-way operation, enabling the Work manager to be configured independently.
Specifying one Work manager for each component service is optional. If we do not specify a Work manager component service that has the one-way operation, the runtime environment uses a default Work manager configured at the server, node, or cell level.
Important:
- Work manager configuration is supported only at the component service level.
- This feature is supported for default and web services bindings.
- Configure Asynchronous beans Work manager. In the console, click Resources > Asynchronous beans > Work managers. Create a new Work manager. Remember the JNDI name provided.
- (dist) Restart the server.
- (dist) Assemble a composite with one-way operation.
- Define the composite definition by adding the WorkManager namespace definition, http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06, and specify the JNDI name of the Work manager configured previously under component service, <workManager ../>, element.
- Use the console to define a Work manager and assign it a JNDI name.
- Restart the server.
- Develop a service component with a non-blocking, one-way operation.
- Specify a Work manager for component service.
- Add the WorkManager namespace definition to the composite definition (.composite file).
The WorkManager namespace definition is http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06; for example:
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0" xmlns:wm="http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06" name="ExampleComposite">For OASIS SCA applications, the WorkManager namespace definition is http://www.ibm.com/xmlns/prod/websphere/sca/1.1; for example:
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:dbsdo= "http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0" xmlns:wm="http://www.ibm.com/xmlns/prod/websphere/sca/1.1" name="ExampleComposite">
- Add the JNDI name of the workManager element to the component service.
<component name="Example_Component"> <service name="Example_Service"> <wm:workManager value="sca/example"/> </service> <implementation.java class="test.sca.binding.sca.ExampleImpl"/> </component>For OASIS SCA applications, the workManager element is under <extensions>; for example:
<component name="Example_Component"> <service name="Example_Service"> <extensions> <wm:workManager value="sca/example"/> </extensions> </service> <implementation.java class="test.sca.binding.sca.ExampleImpl"/> </component>
- Deploy the service component.
- Change the deployed service Work manager setting to a different JNDI name.
- Restart the business application.
- Change the configuration of the Work manager created.
- Restart the business application.
Results
Service operation dispatches occur in the thread pool of the configured Work manager.
Example
- Sample OSOA composite definition with Work manager configuration
- In this sample, the first component runs with the configured Work manager, which has JNDI name sca/test2. The second component does not have a Work manager setting, even though it is one-way; thus, the second component runs with the default Work manager, which is configured at a server, node, or cell level. The third component runs with its Work manager with JNDI name sca/test4.
<?xml version="1.0" encoding="UTF-8"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://samples.myco.com/oneway" xmlns:wm="http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06" name="Composite_2"> <component name="Component_2"> <service name="Component_2"> <wm:workManager value="sca/test2"/> </service> <implementation.java class="test.sca.binding.sca.oneway.Component_2Impl"/> <reference name="component_3" target="Component_3"/> </component> <component name="Component_3"> <implementation.java class="test.sca.binding.sca.oneway.Component_3Impl"/> <reference name="component_4" target="Component_4"/> </component> <component name="Component_4"> <service name="Component_4"> <wm:workManager value="sca/test4"/> </service> <implementation.java class="test.sca.binding.sca.oneway.Component_4Impl"/> </component> </composite>
- Sample service interface with one-way operation
import org.osoa.sca.annotations.OneWay; import org.osoa.sca.annotations.Remotable; @Remotable public interface Component_2 { @OneWay public void test(Message inputText); }
Related concepts
Asynchronous beans