9 Working with Application Context Work-Managers

This chapter provides information about the use of WebLogic's ManagedExecutorService work-manager in Oracle Communications Network Integrity.

This chapter contains the following sections:

ManagedExecutorService Work-Manager Configuration

A ManagedExecutorService extends the Java SE ExecutorService to provide methods for submitting tasks for execution in a Java EE environment. A ManagedExecutorService is usually used to run short-duration asynchronous tasks such as processing of asynchronous methods in Enterprise JavaBean (EJB). When tasks are executed using ManagedExecutorService, they run in managed threads, within the context of the application that submitted them. Each task also has its own explicit transaction and does not participate in the application component’s transaction.

Defining new MES Work-Manager within Network Integrity

You can define a new ManagedExceutorService work-manager for Network Integrity inside weblogic-application.xml under the META-INF folder of NetworkIntergrity.ear. The scope of this work-manager is limited to the application context.

<work-manager>
     <name>wm/workManager</name>
                 <max-threads-constraint>
                                <name>WorkManager_maxthreads</name>
                                <count>5</count>
                                <queue-size>1000</queue-size>
                 </max-threads-constraint>
  </work-manager>
  <managed-executor-service>
       <name>wmMES</name>
       <dispatch-policy>wm/workManager</dispatch-policy>
   </managed-executor-service>
   <resource-env-description>
                <resource-env-ref-name> java:app/env/ wmMES </resource-env-ref-name>
                <resource-link> wmMES </resource-link>
</resource-env-description>
  • max-threads-constraint: Defines the maximum number of active threads that the work-manager will utilise.
  • max-threads-constraint – name: Name of the max-threads-constraint.
  • max-threads-constraint – count: Number of asynchronous threads.
  • max-threads-constraint – queue-size: Size of the queue where all the submitted tasks are held until they get picked up by JVM processor.

Using MES Work-Manager within Network Integrity

To make the work-manager available to Network Integrity, the below configuration must be added inside the application.xml under META_INF folder of NetworkIntegrity.ear file.

<resource-env-ref>
          <resource-env-ref-name>java:app/env/wmMES</resource-env-ref-name>
          <resource-env-ref-type>javax.enterprise.concurrent.ManagedExecutorService</resource-env-ref-type>
</resource-env-ref>

Accessing MES Work-Manager within Network Integrity

You can use the below sample code snippet to access MES work-manager inside any java class to process the tasks asynchronously.

private ManagedExecutorService mes;
                private static String MANAGED_EXECUTOR_SERVICE_IMPORT_JNDI = "java:app/env/wnMES";       
                InitialContext ctx = oracle.communications.platform.util.Utils.getInitialContext();
                mes = (ManagedExecutorService) ctx.lookup(MANAGED_EXECUTOR_SERVICE_IMPORT_JNDI);

Persist Results using Multi-Threading

Network Integrity core has an API persistResults() which persists the entities from the result group.

The process of storing the entities happens in a sequence. If the data volume is high, you may need to store the results simultaneously. You can enable the parallel processing by enabling the PersistResultsInParallel parameter. It is disabled by default. For more information on enabling this parameter, see “NIConfigurationService MBean” in Network Integrity System Administrator's Guide. When this parameter is enabled, Network Integrity will persist multiple entities in a separate asynchronous task by using the MES work-manager configuration.

Network Integrity uses the below MES work-manager configuration by default. You may change the thread count based on the requirement.

<work-manager>
     <name>wm/IntegrityWorkManager</name>
     <max-threads-constraint>
            <name>IntegrityWorkManager_maxthreads</name>
            <count>5</count>
     </max-threads-constraint>
  </work-manager>

Discovery Scan using Multi-Threading

The below work-manager configuration is used by NI discovery scans enabled by multi-threading feature. You may adjust the configuration based on your requirements.

<work-manager>
     <name>wm/IntegrityDiscoverWorkManager</name>
      <max-threads-constraint>
               <name>IntegrityDiscoverWorkManager_maxthreads</name>
               <count>5</count>
               <queue-size>50000</queue-size>
      </max-threads-constraint>
  </work-manager>

<resource-env-ref>
                <resource-env-ref-name>java:app/env/integrityDiscoverMES</resource-env-ref-name>
                <resource-env-ref-type>javax.enterprise.concurrent.ManagedExecutorService</resource-env-ref-type>
</resource-env-ref>

Import Scan using Multi-Threading

The below work-manager configuration is used by NI import scans enabled by multi-threading feature. You may adjust the configuration based on your requirements.

<work-manager>
     <name>wm/IntegrityImportWorkManager</name>
     <max-threads-constraint>
             <name>IntegrityImportWorkManager_maxthreads</name>
             <count>5</count>
             <queue-size>50000</queue-size>
      </max-threads-constraint>
  </work-manager>

<resource-env-ref>
                <resource-env-ref-name>java:app/env/integrityImportMES</resource-env-ref-name>
                <resource-env-ref-type>javax.enterprise.concurrent.ManagedExecutorService</resource-env-ref-type>
</resource-env-ref>