Description of the Berkeley Database Schema

14 Configuring Custom Adapters 14-1 14 Configuring Custom Adapters This chapter describes how to code and register custom adapters, including: ■ Section 14.1, Overview of Custom Adapters ■ Section 14.2, Implementing a Custom Adapter ■ Section 14.3, Passing Login Credentials from an Adapter to a Data Feed Provider ■ Section 14.4, Configuring the Custom Adapter EPN Assembly File ■ Section 14.5, Configuring the Custom Adapter Component Configuration File

14.1 Overview of Custom Adapters

One of the main roles of an adapter is to convert data coming from some channel, such as a market data feed, into Oracle CEP events. These events are then passed to other components in the application, such as processors. An adapter is usually the entry point to an Oracle CEP application. An adapter can also be the exit point of an application so that it receives events from an intermediate component, converts the data into something that an external application can read, and then sends it out. Foreign Exchange FX Example in the Oracle Complex Event Processing Getting Started shows three adapters that read in data from currency data feeds and then pass the data, in the form of a specific event type, to the processors, which are the next components in the network. You can create adapters of different types, depending on the format of incoming data and the technology you use in the adapter code to do the conversion. The most typical types of adapters are those that: ■ Use a data vendor API, such as Reuters, Wombat, or Bloomberg. ■ Convert incoming JMS messages using standard JMS APIs. ■ Use other messaging systems, such as TIBCO Rendezvous. ■ Use a socket connection to the customers own data protocol. Adapters are Java classes that implement specific Oracle CEP interfaces. You register the adapter classes in the EPN assembly file that describes your entire application. You can optionally change the default configuration of the adapter, or even extend the configuration and add new configuration elements and attributes. There are two ways to pass configuration data to the adapter; the method you chose depends on whether you want to dynamically change the configuration after deployment: 14-2 Oracle Complex Event Processing Developers Guide ■ If you are not going to change the configuration data after the adapter is deployed, then you can configure the adapter in the EPN assembly file. ■ If, however, you do want to be able to dynamically change the configuration elements, then you should put this configuration in the adapter-specific component configuration file. This section describes: ■ Section 14.1.1, Custom Adapter Event Sources and Event Sinks ■ Section 14.1.2, Custom Adapter Factories ■ Section 14.1.3, Single and Multi-threaded Adapters

14.1.1 Custom Adapter Event Sources and Event Sinks

Adapters can be event sources, event sinks, or both. Event sources generate events, event sinks receive events.

14.1.1.1 Custom Adapters as Event Sources

You specify that an adapter component in your EPN is an event source by implementing the com.bea.wlevs.ede.api.StreamSource or RelationSource API. The implementation class of a custom adapter that is an event source may be specified as private to the application or as an advertised OSGI service re-usable by other applications. You register adapters in the EPN assembly file using the wlevs:adapter element. For example: wlevs:adapter id=myAdapterSource class=com.acme.MySourceAdapter wlevs:adapter In this example, the Java class MySourceAdapter.java implements the com.bea.wlevs.ede.api.StreamSource or RelationSource API. For more information, see Section 14.2.2.1, Implementing a Custom Adapter as an Event Source .

14.1.1.2 Custom Adapters as Event Sinks

The functionality of custom adapters as event sinks is very similar to that of event sources except that custom adapter event sinks must implement the com.bea.wlevs.ede.api.StreamSink or RelationSink API. Event sinks are not active which means that if they implement the Runnable interface, Oracle CEP does not run them in a separate thread. You reference event sinks in the EPN assembly file using the wlevs:listener element: wlevs:adapter id=myAdapterSink class=com.acme.MySinkAdapter wlevs:adapter wlevs:channel id=myStream wlevs:listener ref=myAdapterSink wlevs:channel In this example, the Java class MySinkAdapter.java implements the com.bea.wlevs.ede.api.StreamSink or RelationSink API.