Using Open MQ as an Oracle CEP Event Source

Posted by seth.white on Oracle Blogs See other posts from Oracle Blogs or by seth.white
Published on Wed, 12 May 2010 16:39:48 -0800 Indexed on 2010/05/13 0:45 UTC
Read the original article Hit count: 401

Filed under:

I helped an Oracle CEP customer recently who wanted to use Open MQ has an event source for their Oracle CEP application.  In this case, the Oracle CEP application was being used to provide monitoring for an electronic commerce website, however, the steps for configuring Open MQ are entirely independent of the application logic. I thought I would list the configuration steps in a blog post in case they might help others in the future. Note that although the Oracle CEP documentation states that only WebLogic and Tibco JMS are "officially" supported, any JMS implementation that provides a Java client should work with Oracle CEP.

The first step is to add an adapter to the application's EPN. This can be done in the usual way, using the Eclipse IDE. The end result is something like the following bit of configuration in the application's Spring application context. Note that the provider attribute value of 'jms-inbound' specifies that the out-of-the-box JMS adapter is being used.

<wlevs:adapter id="helloworldAdapter" provider="jms-inbound">
</wlevs:adapter> 
 

Next, configure the inbound adapter so that it can connect to Open MQ in the Oracle CEP configuration file (config.xml). The snippet below provides an example of what this configuration should look like. The exact values specified for jndi-provider-url, jndi-factory, connection-jndi-name, destination-jndi-name elements will depend on your Open MQ configuration.  For example , if the name of your Open MQ topic destination is 'ElectronicCommerceTopic', then you would specify that as the destination-jndi-name.  The name of your Open MQ connection factory goes in the connection-jndi-name element.

In my simple example, I also specify in event-type element so that the out-of-the-box JMS adapter will attempt to automatically convert incoming messages to events of type HelloWorldEvent. In a more complex application, one would configure a custom converter on the JMS adapter to convert from messages to events.  The Oracle CEP 11.1.3 documentation describes how to do this.

 

<jms-adapter>
    <name>helloworldAdapter</name>
    <event-type>HelloWorldEvent</event-type>
    <jndi-provider-url>file:///C:/Temp</jndi-provider-url>
    <jndi-factory>com.sun.jndi.fscontext.RefFSContextFactory</jndi-factory>
    <connection-jndi-name>YourJMSConnectionFactoryName</connection-jndi-name>
    <destination-jndi-name>YourJMSDestinationName</destination-jndi-name>
</jms-adapter>
 

Finally, one needs to package the client-side Open MQ jars so that the classes that they contain are available to the Oracle CEP runtime. The recommended way for doing this in the Oracle CEP 11.1.3 release is to package the classes as a library module or simply place them in the application bundle.  The advantage of deploying the classes as a library module is that they are available to any application that wants to connect to Open MQ. In my case, I packaged the classes in my application bundle.

A best practice when you want to include additional jars in your application bundle is to create a 'lib' directory in your Eclipse project and then copy the required jars into that directory.  Then, use the support that Eclipse provides to add the jars to the bundle classpath (which makes the classes part of your application in the same way that regular application classes are), and export all of the classes from your application bundle so that they are available to the Oracle CEP server runtime.  The screenshot below Illustrates how this is done in Eclipse.  The bundle classpath contains two Open MQ jars and all packages in the jars are exported.

 

image

 

Finally, import the javax.jms and javax.naming packages into the application module as these are needed by the Open MQ classes. The screenshot below shows the complete list of package imports for my sample application.

 

image 

 

Once you have completed these steps, you should be able to build and deploy your application and begin receiving inbound messages from Open MQ.

Technorati Tags: ,,,,

© Oracle Blogs or respective owner