Top
Interstage Big DataComplex Event Processing Server V1.1.0 User's Guide
FUJITSU Software

5.7.3 Implementing a Collaboration Application

This section explains how to implement a collaboration application, as follows:

5.7.3.1 Implementing an Event Sender Application

Implement an application to send events to the CEP engine.

Implement the application according to the type of input adapter to be used.

Refer to Chapter 3, "Input Adapter Reference" in the Developer's Reference for information on sample programs by input adapter type.

5.7.3.2 Implementing a User-developed Web Service

Implement a Web service application to be called from the SOAP listener.

5.7.3.2.1 Web service implementation procedure

This section explains the Web service implementation procedure.

  1. Create a WSDL.

    Create a WSDL (interface definition) for a user-developed Web service from the interface information (Web service URL, namespace, prefix, and method) of the Web service to be called, that was defined in the SOAP listener definition, and from the parameters that are specified in the complex event processing statements (SELECT statements).

    Below is an example of the association between the complex event processing statement (SELECT statement) for detecting the target events, the SOAP listener definition associated with that rule, and SOAP messages generated from the SOAP listener.

    Figure 5.5 Association between a rule definition, listener definition, and SOAP messages to be sent

    A sample WSDL for a Web service for receiving these SOAP messages is shown below. This WSDL defines a message receive-only (one-way) Web service. If it is implemented as a Web service that returns a response to the CEP engine (request-response), the CEP engine ignores this response.

    Table 5.8 Sample WSDL
    001
    002

    003

    004

    005

    006

    007

    008

    009

    010

    011

    012

    013

    014

    015

    016

    017

    018

    019

    020

    021

    022

    023

    024

    025

    026

    027

    028

    029

    030

    031

    032

    033

    034

    035

    036

    037

    038

    039

    040

    041

    042

    043

    044

    045

    046

    047

    048

    049

    050
    <?xml version='1.0' encoding='UTF-8'?>
    <definitions

    targetNamespace="
    http://example.com/exampleNamespace"
    xmlns="http://schemas.xmlsoap.org/wsdl/"

    xmlns:tns="
    http://example.com/exampleNamespace"
    xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"

    xmlns:xs="http://www.w3.org/2001/XMLSchema">


    <types>

    <xs:schema elementFormDefault="qualified"

    targetNamespace="
    http://example.com/exampleNamespace" >
    <xs:element name="
    rootElement">
    <xs:complexType>

    <xs:sequence>

    <xs:element name="
    property1" type="xs:string" />
    <xs:element name="
    property2" type="xs:string" />

    </xs:sequence>

    </xs:complexType>

    </xs:element>

    </xs:schema>

    </types>


    <message name="notifyMessage">

    <part name="body" element="tns:
    rootElement" />
    </message>


    <portType name="eventReceiverPortType">

    <operation name="notifyOperation">

    <input message="tns:notifyMessage" />

    </operation>

    </portType>


    <binding name="eventReceiverSOAP
    Binding" type="tns:eventReceiverPortType">
    <soapbind:binding transport="http://schemas.xmlsoap.org/soap/http"

    style="document" />

    <operation name="notifyOperation">

    <soapbind:operation soapAction="" />

    <input>

    <soapbind:body use="literal" />

    </input>

    </operation>

    </binding>


    <service name="eventReceiverService">

    <port name="eventReceiverSOAP
    Port" binding="tns:eventReceiverSOAPBinding">
    <soapbind:address location="
    http://example.com/serviceEndPoint" />
    </port>

    </service>

    </definitions>

    Modifying, as follows, the underlined parts according to a rule definition or SOAP listener definition allows the WSDL above to be used to generate a template of the Web service to be created:

    • Line numbers 003, 005, and 011

      Use the value of the namespace in the SOAP listener definition as the target namespace of the WSDL ("targetNamespace" attribute of the "definitions" element), the declaration of the target namespace prefix ("xmlns:tns" attribute of the "definitions" element), and the target namespace of the XML schema in the WSDL ("targetNamespace" attribute of the "xs:schema" element in the "types" element).

    • Line numbers 012 and 025

      Use the value of the root element in the SOAP listener definition as the name of the root element of messages to be defined in the XML schema in the WSDL ("name" attribute of the "xs:element" element in "xs:schema" element in the "types" element) and the element defined as a message of the WSDL ("element" attribute of the "part" element in the "message" element).

    • Line numbers 015 and 016

      Use the output property name of the complex event processing statement (SELECT statement) as the name of the subelement of the root element to be defined in the XML schema in the WSDL ("name" attribute of the "xs:element" element under the root element definition in the "types" element).

      Create as many similar lines as the number of properties to be output. In the example above, this element type ("type" attribute of the "xs:element" element) is specifying a string ("xs:string"). Setting this to suit the property type will, depending on the tool used, generate source code according to the type, so type conversion will no longer be required in the program.

    • Line number 047

      In the final WSDL for service publishing, the actual URL of the service will be entered in the "location" attribute of the "soapbind:address" element under the "service" element, and this will also be the value of the connection URL in the listener definition. However, this connection URL is often unsure at development, so there is no problem with leaving it as in the sample above.

  2. Implement the Web service application.

    Based on the created WSDL, output a template for the Web service application from the development tool being used, and then add the application logic to it.

5.7.3.3 Implementing a User-developed Java Class (Custom Listener)

Implement a user-developed Java class to be called via the custom listener of the CEP engine.

5.7.3.3.1 CustomListener interface

A user-developed Java class must implement the following Java interface:

com.fujitsu.cspf.cep.CustomListener

The interface is contained in /opt/FJSVcep/cep/lib/CepServerCustom.jar on the CEP Server. Copy CepServerCustom.jar to the Java development environment you are using, set the class path, and develop the Java class.

5.7.3.3.2 Custom log

Logs can be output from a user-developed Java class to the log file (custom log) for the custom listener. The output destination of the custom log is as follows:

/var/opt/FJSVcep/cep/cep/logs/EngineLog/cepEngineName/custom.log

Output

Use the Apache Log4j class (org.apache.log4j.Logger) for implementation.

Obtain a log output instance using the following method (the argument must be "custom"):

Logger myLogger = Logger.getLogger("custom");

Information

The Apache Log4j jar file is located in /opt/FJSVcep/log4j/lib/log4j-1.2.16.jar.

Use the fatal, error, warn, and info methods of the Logger class to output logs.

myLogger.error("xxxxxx");

Note

You cannot use the trace or debug methods of the org.apache.log4j.Logger class.

5.7.3.3.3 Compilation

Compile the source code you created, and generate a class file or jar file.

If using javac of JDK7 or later, specify the "-target 1.6" option when compiling the source code.

5.7.3.4 Implementing an Event Log Analysis Application

Implement an application to analyze event logs. Implement the application using the Hadoop API. Refer to the Interstage Big Data Parallel Processing Server manuals for details.

5.7.3.5 Implementing a Terracotta Application

Implement a Terracotta application. Refer to the Interstage Terracotta BigMemory Max manuals for details.