IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing monitor models > Create monitor models > Defining monitor details models > Defining outbound events
Create SCA services for Monitor action services
When Business Monitor action services is installed on a WebSphere platform that supports the Service Component Architecture, such as Process Server or WebSphere Enterprise Service Bus, Monitor action services can call an SCA service when a situation event is received.
To enable Monitor action services to call an SCA service, the SCA service must be implemented to a specific interface, which is defined in the WBI-ActionManager file.
The following high-level steps are required to create the SCA service in Integration Designer:
The Monitor action services and the deployed SCA service must both run on the same server. Also, the Common Event Infrastructure and Startup Beans services must be enabled for this server. They must also be configured support the Service Component Architecture components, either locally or remotely.
Procedure
- Switch to the Business Integration perspective.
- Import the WBI-ActionManager project interchange file. The file is installed as part of the Business Monitor development toolkit and is located at \wbmonitor\library\WBI-ActionManager.zip. Importing the file creates a Library project that contains the ActionManagerNotification interface and SituationEvent data type.
- Create a new Module project and select the WBI-ActionManager as a dependency of the module.
- Add a Java™ component to the assembly diagram and name it appropriately; for example, ReceiveEvent.
- Add the ActionManagerNotification interface to the component.
- Add an export to the assembly diagram and name it appropriately; for example, ActionManagerNotificationExport.
- Wire the export and the Java component.
- Generate the SCA Binding for the export.
- Double-click the Java component to add the implementation to the component. Create a suitable package for the service. The Java implementation file is displayed. It includes a method named receiveActionManagerEvent(DataObject situationEvent), which is the method that is called by the Monitor action services for an SCA notification template.
- Create your implementation. (See the implementation example below.) Your assembly diagram should show a Java component that implements the ActionManagerNotification interface connected to an export that implements the same interface:
- Deploy your service.
- Create an SCA notification template using the WebSphere Application Server administrative console. See "Notification templates." The SCA notification requires the name of the Module and the Export name.
- Associate the action template definition with a situation event. See "Binding situation events to action services." The SCA Service will be called when the Monitor action services receives the situation event and will pass the situation event to the SCA service.
Example
The method in the following example receives a DataObject of type SituationEvent and contains a single String attribute named cbeXML. This attribute contains the Situation Event Common Base Event that is received by Monitor action services. The example code shows how cbeXML can be extracted and turned back into a Common Base Event object ready to be processed by the SCA service.When calling the interfaces for Monitor action services, use Action Manager as demonstrated in the following example
import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; import org.eclipse.hyades.logging.events.cbe.FormattingException; import org.eclipse.hyades.logging.events.cbe.util.EventFormatter; import commonj.sdo.DataObject; import com.ibm.websphere.sca.ServiceManager; public class ReceiveEventImpl { /** * Default constructor */ public ReceiveEventImpl() { super(); } /** * Return a reference to the component service instance for this * implementation class. This method should be used when passing this service * to a partner reference or if you want to invoke this component service * asynchronously. * * @generated (com.ibm.wbit.java) */ private Object getMyService() { return (Object) ServiceManager.INSTANCE.locateService("self"); } /** * Method generated to support implemention of operation * "receiveActionManagerEvent" defined for WSDL port type * named "ActionManagerNotification". * * The presence of commonj.sdo.DataObject as the return type or as a * parameter type conveys that it is a complex type. Refer to the WSDL * Definition for more information about the type of input, output and faults. */ public void receiveActionManagerEvent(DataObject situationEvent) { System.out.println("Entered receiveActionManagerEvent do=" + situationEvent); String cbeXML = situationEvent.getString("cbeXML"); System.out.println("cbeXML=" + cbeXML); try { System.out.println("Creating CommonBaseEvent"); CommonBaseEvent event = EventFormatter.eventFromCanonicalXML(cbeXML); System.out.println("CommonBaseEvent = " + event); // TODO Process Common Base Event } catch (FormattingException e) { System.out.println("FormattingException " + e.getLocalizedMessage()); e.printStackTrace(); } System.out.println("Exiting receiveActionManagerEvent"); } }