How to Configure a JMS Adapter for Oracle WebLogic Server JMS Manually

7-10 Oracle Complex Event Processing Developers Guide See Section 4.7.5, How to Import a Package .

7.2.4 How to Configure a JMS Adapter for Tibco EMS JMS Manually

Oracle CEP supports TIBCO Enterprise Message Service EMS version 4.2.0 or higher. To use the Tibco EMS JMS provider, you must add the following Tibco EMS client JAR files to the Oracle CEP server library directory: ■ tibjms.jar For more information, see: ■ Section 7.2, Configuring a JMS Adapter for a JMS Service Provider ■ Section 24.1.3.1, Library Directory You can manually configure the built-in JMS inbound and outbound adapter to use the Tibco EMS JMS provider. The simplest way to create and configure a JMS adapter is using the Oracle CEP IDE for Eclipse adapter wizard as Section 7.2.1, How to Configure a JMS Adapter Using the Oracle CEP IDE for Eclipse describes. After using the adapter wizard to create and specify the basic JMS adapter configuration, review this procedure to complete the configuration. To configure a JMS adpater for Tibco EMS JMS manually: 1. In the EPN assembly file of the application, add a wlevs:adapter element for each inbound and outbound JMS adapter you want to use in your application. Example 7–7 shows the wlevs:adapter element for a JMS inbound adapter. Example 7–7 wlevs:adapter Element for Inbound Adapter wlevs:adapter id=inboundJmsAdapter1 provider=jms-inbound ... wlevs:adapter See: ■ Section 7.5.1, JMS Inbound Adapter EPN Assembly File Configuration ■ Section 7.5.2, JMS Outbound Adapter EPN Assembly File Configuration 2. In the component configuration file of the application, add a jms-adapter element for each inbound and outbound JMS adapter you want to use in your application. Example 7–8 shows the jms-adapter element for the JMS inbound adapter in Example 7–7 . Example 7–8 jms-adapter Element for Inbound Adapter jms-adapter nameinboundJmsAdapter1name ... jms-adapter For each jms-adapter element, the name child element must be set to the corresponding wlevs:adapter element id child element. See: ■ Section 7.6.1, JMS Inbound Adapter Component Configuration Configuring JMS Adapters 7-11 ■ Section 7.6.2, JMS Outbound Adapter Component Configuration 3. Decide how you want to convert between JMS messages and Oracle CEP event types: a. If you want the JMS adapters to perform automatic conversion, specify an event type using the jms-adapter element event-type child element in the JMS adapter component configuration file. See: – Section 7.6.1, JMS Inbound Adapter Component Configuration – Section 7.6.2, JMS Outbound Adapter Component Configuration b. If you want the JMS adapters to perform custom conversion, create a custom converter Java class and register it in the EPN assembly file. See Section 7.3, Creating a Custom Converter Between JMS Messages and Event Types . 4. Configure the jms-adapter elements for your Tibco EMS JMS provider as Example 7–9 shows: Example 7–9 jms-adapter Element With Tibco EMS JMS Configuration jms-adapter nameinboundJmsAdapter1name ... jndi-provider-urltcp:TIBCOHOST:PORTjndi-provider-url jndi-factorycom.tibco.tibjms.naming.TibjmsInitialContextFactoryjndi-factory connection-jndi-nameCONNECTION_NAMEconnection-jndi-name destination-jndi-nameDESTINATION_NAMEdestination-jndi-name ... jms-adapter Where: ■ TIBCOHOST : the hostname of the Tibco EMS JMS provider host. ■ PORT : the Tibco EMS JMS provider port. ■ DESTINATION_NAME : the destination JNDI name of the Tibco EMS JMS destination, such as TibcoRequestQueue1. ■ CONNECTION_NAME : the connection JNDI name of the Tibco EMS JMS connection factory you defined in the Tibco EMS JMS server, such as TibcoQueueConnectionFactory. See: – Section 7.6.1, JMS Inbound Adapter Component Configuration – Section 7.6.2, JMS Outbound Adapter Component Configuration 5. If you specify JMS provider client passwords in the component configuration file, consider encrypting them. See Section 7.4, Encrypting Passwords in the JMS Adapter Component Configuration File . 6. Create a JMS client application library that contains the following: ■ tibjms.jar ■ If you are using Java Object messages, the Java classes used for messaging need to be packaged in a library bundle. 7-12 Oracle Complex Event Processing Developers Guide You may include these Java classes in this JMS client application library. For more information, see Section 24.1.3.3, Creating Application Libraries . For a specific JMS provider example, see Section 7.2.4, How to Configure a JMS Adapter for Tibco EMS JMS Manually . 7. Copy the application library to the appropriate Oracle CEP server application library directory: a. If your bundle is a driver, you must put it in the library extensions directory. See Section 24.1.3.2, Library Extensions Directory . b. If your bundle is not a driver, you may put it in the library directory. See Section 24.1.3.1, Library Directory For more information, see Section 24.3.4, How to Update an Application Library Using Oracle CEP IDE for Eclipse . 8. If you created a custom converter class in step 3, update the MANIFEST.MF file of your application to add the following packages to the Import-Package header: Import-Package: javax.jms,javax.naming, ... ... See Section 4.7.5, How to Import a Package .

7.3 Creating a Custom Converter Between JMS Messages and Event Types

If you want to customize the conversion between JMS messages and event types you must create your own converter bean. This section describes: ■ Section 7.3.1, How to Create a Custom Converter for the Inbound JMS Adapter ■ Section 7.3.2, How to Create a Custom Converter for the Outbound JMS Adapter

7.3.1 How to Create a Custom Converter for the Inbound JMS Adapter

The custom converter bean for an inbound JMS must implement the com.bea.wlevs.adapters.jms.api.InboundMessageConverter interface. This interface has a single method: public List convertMessage message throws MessageConverterException, JMSException; Note: The JMS client application library must: ■ Export all provider-specific packages. ■ Export the Java classes used for messaging, if applicable. ■ Import javax.jms and javax.naming. The application bundle does not need to export the provider-specific packages. The application bundle must import Java classes used for messaging, if applicable. Configuring JMS Adapters 7-13 The message parameter corresponds to the incoming JMS message and the return value is a List of events that will be passed on to the next stage of the event processing network. See the Oracle Fusion Middleware Java API Reference for Oracle Complex Event Processing for a full description of these APIs. To create a custom converter for the inbound JMS adapter: 1. Using the Oracle CEP IDE for Eclipse or your preferred IDE, add a Java class to your application project. 2. Implement the com.bea.wlevs.adapters.jms.api.InboundMessageConverter interface. Example 7–10 shows a possible implementation. Example 7–10 Custom Converter for an Inbound JMS Adapter package com.customer; import com.bea.wlevs.adapters.jms.api.InboundMessageConverter; import com.bea.wlevs.adapters.jms.api.MessageConverterException; import com.bea.wlevs.adapters.jms.api.OutboundMessageConverter; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Session; import javax.jms.TextMessage; import java.util.ArrayList; import java.util.List; public class MessageConverter implements InboundMessageConverter, OutboundMessageConverter { public List convertMessage message throws MessageConverterException, JMSException { TestEvent event = new TestEvent; TextMessage textMessage = TextMessage message; event.setString_1textMessage.getText; List events = new ArrayList1; events.addevent; return events; } public ListMessage convertSession session, Object inputEvent throws MessageConverterException, JMSException { TestEvent event = TestEvent inputEvent; TextMessage message = session.createTextMessage Text message: + event.getString_1 ; ListMessage messages = new ArrayListMessage; messages.addmessage; return messages; } } 3. Specify the converter in your application EPN assembly file as Example 7–11 shows: ■ Register the convert class using a bean element. ■ Associate the converter class with the JMS adapter by adding a wlevs:instance-property with name set to converterBean and ref set to the id of bean. Example 7–11 Specifying a Converter Class for an Inbound JMS Adapter in the EPN Assembly File ...