Stream and Relation Sources

1-8 Oracle Complex Event Processing Developers Guide com.bea.wlevs.ede.api.RelationSource The RelationSource interface has one method, setEventSender; at runtime the event source component is injected with a com.bea.wlevs.ede.api.RelationSender instance. The RelationSender instance, in turn, has sendUpdateEvent and sendDeleteEvent methods that the component invokes to actually send events to the next component in the EPN. When you configure a channel as a relation, the channel attribute primary-key determines event identity. For more information, see Section 9.1.2.2, Channels as Relations . For sendDeleteEvent, you must send an instance of the same event type as that configured for the channel. For sendInsertEvent, a unique constraint violation exception will be raised and the input event discarded if an event with the same primary key is already in the relation. For sendUpdateEvent, an invalid update tuple exception will be raised and the input event discarded if an event with the given primary key is not in the relation. If you enable batching on a channel you configure as a relation, then components that send events to that channel must implement the com.bea.wlevs.ede.api.BatchRelationSender interface. The BatchRelationSender interface has a sendEvents method that the component invokes to send a batch of events of type insert, update, and delete downstream to a BatchRelationSink. For more information, see Section 9.1.6, Batch Processing Channels .

1.1.3.3 Stream and Relation Sinks

All components that consume events must implement one of the following interfaces: ■ com.bea.wlevs.ede.api.StreamSink ■ com.bea.wlevs.ede.api.RelationSink com.bea.wlevs.ede.api.StreamSink The StreamSink interface has a single callback method, onInsertEvent, that components implement to receive a list of events from the previous component in the EPN. If you enable batching on a channel, then components that receive events from that channel must implement the com.bea.wlevs.ede.api.BatchStreamSink interface. The BatchStreamSink interface has an onInsertEvents call-back method for receiving a batch of events of type insert. Events of type insert are used to model streams, as streams are append-only. In the case of single event, call-back method of StreamSink will be invoked. For more information, see Section 9.1.6, Batch Processing Channels . com.bea.wlevs.ede.api.RelationSink The RelationSink interface extends StreamSink to model an Oracle CQL relation sink. The RelationSink interface also provides an onDeleteEvent and onUpdateEvent methods. If you enable batching on a channel you configure as a relation, then components that receive events from that channel must implement the com.bea.wlevs.ede.api.BatchRelationSink interface. The BatchRelationSink interface has an onEvents call-back method for receiving a Overview of Creating Oracle CEP Applications 1-9 batch of events for each event type of insert, update, and delete. If there is no event of a particular kind, then the corresponding Collection will be an empty Collection. For more information, see Section 9.1.6, Batch Processing Channels .

1.1.3.4 Transmitting Events in the EPN: Examples

The following example is based on the HelloWorld example that Figure 1–1 shows. It is modified here to illustrate: ■ Creating the HelloWorldEvent as a Tuple Event ■ Sending Events from the HelloWorldAdapter as a StreamSource ■ Receiving Events in the HelloWorldBean as a StreamSink ■ Sending Events from the HelloWorldBean as a StreamSource Figure 1–1 The HelloWorld Example Event Processing Network For more information, see: ■ Chapter 14, Configuring Custom Adapters ■ Chapter 15, Configuring Custom Event Beans ■ Chapter 16, Configuring Custom Spring Beans ■ HelloWorld Example in the Oracle Complex Event Processing Getting Started Creating the HelloWorldEvent as a Tuple Event First, create the tuple event in the EPN assembly file: wlevs:event-type-repository wlevs:event-type type-name=HelloWorldEvent wlevs:properties wlevs:property name=message type=char length=1000 wlevs:properties wlevs:event-type wlevs:event-type-repository Sending Events from the HelloWorldAdapter as a StreamSource Modify the HelloWorldAdapter to inject an EventTypeRepository instance at runtime by adding a setEventTypeRepository method using the Service annotation: Service public void setEventTypeRepositoryEventTypeRepository etr { etr_ = etr; }