Monday, March 21, 2011

Desktop Events with OpenSpan and Oracle CEP - Part 2

On the first part of this tutorial we walked through the steps of Oracle WebLogic JMS configuration. This is a very important step since it's the base underlying communication system between the major components for the integration between the applications part of this demonstration.


9. Assuming that everything works fine on the infrastructure side of the project you’re now ready to start developing your Oracle CEP application. Go to Oracle Enterprise Pack for Eclipse (Start Menu > Oracle WebLogic > Oracle Enterprise Pack for Eclipse).

10. Create a new Oracle CEP Application Project. Go to File > New > Other > Oracle CEP > Oracle CEP Application Project.

11. Name the project OpenSpan_Tutorial and leave all other fields as default.

12. Click Next.

13. On the New Oracle CEP Application Project select “Create an Oracle CEP Application using an application template” and choose Hello World as the template.

14. Click Finish.

15. At this point you should have an Oracle EPN similar to this:


16. Right-click at the OpenSpan_Tutorial canvas and select New… Adapter. Name it jmsAdapter.
17. Go to the config.xml file under the META-INF\wlevs\ directory and add the following configuration:


<jms-adapter>
<name>jmsAdapter</name>
<jndi-provider-url>t3://localhost:7001</jndi-provider-url>
<destination-jndi-name>osevents_SampleQ1</destination-jndi-name>
<user>weblogic_username</user>
<password>weblogic_password</password>
<session-transacted>false</session-transacted>
</jms-adapter>


The above configuration tells the Oracle CEP application to connect to the JMS Provider configured under Oracle WebLogic.


18. Go back to the OpenSpan Tutorial EPN and remove the connection between the helloWorldAdapter adapter and the helloworldInputChannel.

19. Add a connection from the jmsAdapter to the helloworldInputChannel.

20. Right-click on the jmsAdapter component and choose Go to Assembly Source. Add the following to the helloworld-context.xml file


<wlevs:adapter id="jmsAdapter" provider="jms-inbound">
<wlevs:listener ref="helloworldInputChannel" />
<wlevs:instance-property name="converterBean" ref="eventAdapter"/>
</wlevs:adapter>


You’ll also need to add the following bean definition:

<bean id="eventAdapter"class="com.bea.wlevs.example.helloworld.HelloWorldBean"/>


21. Go to the HelloWorldBean java class and add the following imports:


import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;
import com.bea.wlevs.adapters.jms.api.InboundMessageConverter;
import com.bea.wlevs.adapters.jms.api.MessageConverterException;


22. Change the HelloWorldBean class to implement InboundMessageConverter. To do that, change the class signature to be:


public class HelloWorldBean implements StreamSink, InboundMessageConverter {


23. Then, implement the following required method:


public List convert(Message message) throws MessageConverterException, JMSException {
javax.jms.TextMessage textMessage = (TextMessage) message;
System.out.println("Message Processed: " + textMessage.getText());
return null;
}




24. Save and close all files.

25. Your Oracle EPN should be similar to the following picture:


26. It’s time to deploy your project. Go to the Servers view. Right-click on your Oracle CEP v11.1 instance, click on Add and Remove, select the OpenSpan Tutorial and click on Add. Click Finish.

27. Your project should be deployed successfully and you should see a message similar to this on the Eclipse console:


<Mar 18, 2011 9:43:50 PM EDT> <Notice> <Deployment> <BEA-2045000> <The application bundle "OpenSpan_Tutorial" was deployed successfully to file:/D:/Oracle/Middleware/user_projects/domains/ocep_domain/defaultserver/applications/OpenSpan_Tutorial/OpenSpan_Tutorial.jar with version 1300499030501>
<Mar 18, 2011 9:43:51 PM EDT> <Notice> <Spring> <BEA-2047000> <The application context for "OpenSpan_Tutorial" was started successfully>

Setting Up Local Environment for Developing Oracle Intelligent Bots Custom Components

Oh the joy of having a local development environment is priceless. For most cloud based solutions the story repeats itself being hard to tr...