How to Configure an HTTP Pub-Sub Adapter Using the Oracle CEP IDE for Eclipse

8-8 Oracle Complex Event Processing Developers Guide http-pub-sub-adapter nameremoteSubscribername server-urlhttp:myhost.com:9102pubsubserver-url channelchannel3channel event-typecom.mycompany.httppubsub.PubsubEventevent-type http-pub-sub-adapter Be sure this event type has been registered in the EPN assembly file by specifying it as a child element of the wlevs:event-type-repository element. 7. Finally, if the HTTP pub-sub server to which the Oracle CEP application is publishing requires user authentication, add user and password or encrypted-password elements to specify the username and password or encrypted password. For example: http-pub-sub-adapter nameremotePublishername server-urlhttp:myhost.com:9102pubsubserver-url channelchannel1channel event-typecom.mycompany.httppubsub.PubsubEventevent-type userwlevsuser passwordwlevspassword http-pub-sub-adapter 8. Optionally create a converter Java class if you want to customize the way the inbound or outbound messages are converted into event types. This step is optional because you can let Oracle CEP make the conversion based on mapping property names between the messages and a specified event type. See Section 8.3, Creating a Custom Converter Between the HTTP Pub-Sub Messages and Event Types. 9. If you are going to use the local HTTP pub-sub server associated with the Oracle CEP instance for local publishing, use Visualizer, the Oracle CEP Administration Tool, to add new channels with the channel pattern required by your application. For details, see How to Configure Security for an HTTP Publish-Subscribe Channel in the Oracle Complex Event Processing Visualizer Users Guide. 10. Update the EPN assembly file, adding declarations for each built-in pub-sub adapter you are adding to your application. See Section 8.4, Configuring the HTTP Pub-Sub Adapter EPN Assembly File. 11. Update the MANIFEST.MF file of your application, adding the package com.bea.core.encryption to the Import-Package header. For example: Import-Package: com.bea.core.encryption com.bea.wlevs.adapter.defaultprovider;version=11.1.1.4_0, ... See Section 24.2.2.1, Creating the MANIFEST.MF File for additional information on the manifest file.

8.3 Creating a Custom Converter Between the HTTP Pub-Sub Messages and Event Types

If you want to customize the way a message either inbound via a HTTP pub-sub adapter for subscribing or outbound via an HTTP pub-sub adapter for publishing is converted to an event type, or vice versa, you must create your own converter bean. Configuring HTTP Publish-Subscribe Server Adapters 8-9 The custom converter bean for an inbound HTTP pub-sub message must implement the com.bea.wlevs.adapters.httppubsub.api.InboundMessageConverter interface. This interface has a single method: public List convertJSONObject message throws Exception; The message parameter corresponds to the incoming HTTP pub-sub message and the return value is a List of events that will be passed on to the next stage of the event processing network. The incoming message is assumed to be the JSON format. The custom converter bean for an outbound HTTP pub-sub message must implement the com.bea.wlevs.adapters.httppubsub.api.OutboundMessageConverter interface. This interface has a single method: public ListJSONObject convertObject event throws Exception; The parameters correspond to an event received by the outbound HTTP pub-sub adapter from the source node in the EPN and the return value is a List of JSON messages. See the Oracle Fusion Middleware Java API Reference for Oracle Complex Event Processing for a full description of these APIs. The following example shows the Java source of a custom converter bean that implements both InboundMessageConverter and OutboundMessageConvert; this bean can be used for both inbound and outbound HTTP pub-sub adapters: package com.sample.httppubsub; import com.bea.wlevs.adapters.httppubsub.api.InboundMessageConverter; import com.bea.wlevs.adapters.httppubsub.api.OutboundMessageConverter; import com.bea.httppubsub.json.JSONObject; import java.util.List; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; public class TestConverter implements InboundMessageConverter, OutboundMessageConverter { public List convertJSONObject message throws Exception { List eventCollection = new ArrayList; PubsubTestEvent event = new PubsubTestEvent; event.setMessageFrom TestConverter: + message; eventCollection.addevent; return eventCollection; } public ListJSONObject convertObject event throws Exception { ListJSONObject list = new ArrayListJSONObject1; Map map = new HashMap; map.putmessage, PubsubTestEvent event.getMessage; list.addnew JSONObjectmap; return list; } } You can use the GSON Java library to help you convert Java objects to JSON format. For more information, see: ■ http:www.json.org ■ http:code.google.compgoogle-gson