10 Working with Scan Run Complete Notifications

This chapter describes an Oracle Communications Network Integrity event notification, Scan Complete Notification, which allows external components to receive asynchronous event notification messages about the completion of scans.

You can develop a client to monitor event notifications, to and trigger follow-on actions.

About Clients for Monitoring Scan Run Complete Notification Messages

You can develop a message-driven bean (MDB) or Java messaging system (JMS) client that listens to the Network Integrity event notification JMS topic (oracle/communications/integrity/EventNotificationTopic) for scan-complete notification messages. For example, you can write post-processing logic that listens for messages that trigger other scans or send emails or SMS messages using the MDB/JMS client.

Develop the MDB/JMS client to listen to the Network Integrity application server for the JMS topic. The client must belong to the NetworkIntegrityRole group to access the JMS topic. See Network Integrity System Administrator's Guide for more information on the NetworkIntegrityRole group.

Table 10-1 lists the properties used by EventNotificationTopic for client filtering.

Table 10-1 EventNotificationTopic Properties for Client Filtering

Property Description


Indicates the final scan run state:




Scan Action Name

Indicates the name of the scan action.

Scan Action Type

Indicates the type of the scan action:




Discrepancy Detection

A Boolean that indicates whether discrepancy detection was enabled on the scan action:

  • 1: discrepancy detection enabled.

  • 0: discrepancy detection not disabled.

Notification messages also contain other properties which may be useful to you. For example, the ScanRunId can be obtained from the message body, which retrieves additional information about the scan run.

The following example is a sample MDB/JMS client implementation model:

package model;
import javax.annotation.Resource;
import javax.annotation.security.RunAs;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import weblogic.javaee.MessageDestinationConfiguration;
@MessageDriven(activationConfig =
    { @ActivationConfigProperty(propertyName = "connectionFactoryJndiName",
        propertyValue = "oracle/communications/integrity/NIXATCF"),
        @ActivationConfigProperty(propertyName = "destinationName", propertyValue = "oracle/communications/integrity/EventNotificationTopic"),
            @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic")
    } , mappedName = "oracle/communications/integrity/EventNotificationTopic")
@MessageDestinationConfiguration(connectionFactoryJNDIName = "oracle/communications/integrity/NIXATCF")
public class MyEjbTestBean implements MessageListener {
    javax.ejb.MessageDrivenContext context;
    public void onMessage(javax.jms.Message message) {
        TextMessage text = (TextMessage)message;
        try {
            // write post-processing logic here
            // like trigger other scans, or send e-mails or SMS messages
                System.out.println("entered mdb.... ");
                System.out.println("received the following message: " );
                System.out.println("Status : "+text.getStringProperty("Status"));
                System.out.println("Scan_Action_Name : "+text.getStringProperty("Scan_Action_Name"));
                System.out.println("Scan_Action_Type : "+text.getStringProperty("Scan_Action_Type"));
                System.out.println("Discrepancy_Detection : "+text.getBooleanProperty("Discrepancy_Detection"));
                System.out.println("scan txt : "+text.getText());
        } catch (JMSException e) {
            //Add log statements here

Implementing Custom Code to Stop a Scan

A Network Integrity discovery cartridge typically comprises actions that include processors, which run sequentially in an iterative manner based on conditions (True or False).

The action controller sets the running sequence of the processors based on the order in which the processors are configured. Usually a processor is invoked only once and after its completion, the controller invokes the next processor, until all processors in an action are invoked. However, one or more processors may be run repeatedly in an iterative manner.

For example, when importing an inventory system, it is typical to first get a list of devices from the inventory system, then go through the list of devices, and then import each device individually into Network Integrity. In this example, the processor importing a single device is repeatedly run for all the devices in the returned device list.

A running scan does not stop immediately when you click Stop Scan. If a processor in a scan had already started before you clicked Stop Scan, the processor continues to run until its completion; the next processor in the sequence looks for the value of the condition and the custom code in its invoke method to stop the processor; if the condition is True, the scan is stopped before the next processor starts and all the results of the scan are deleted.

You can add the custom code to any processor depending on its functionality and your requirements. The amount of time that a scan will take to stop depends on how you configure the processors and how you implement the custom code to stop the processors.

To stop a scan when you click Stop Scan, Oracle recommends that you add the following custom code to the beginning of the processor's invoke method and ensure that this code resides outside the try/catch block:

logger.info("Scan is stopped, interrupting data collection");
// Add custom code here to close any open resources, such as connections, sockets,
// sessions, and so on.
throw new ProcessorException("Scan is interrupted");