Friday, 29 May 2020

Configuring JMS Consumer with OUAF IWS (Inbound Web Service)

This blog is aimed at describing the configuration to be done for mapping an Inbound Web Service with a JMS consumer for all OUAF products.

Oracle has already provided the documentation for mapping XAI inbound webservice with JMS consumer. [Oracle WebLogic JMS Integration and Oracle Utilities Application Framework (Doc Id: 1308181.1)]

Using above documentation you can configure a JMS consumer to monitor a JMS queue and hit the XAI inbound service of OUAF framework whenever a message arrives in the queue.

Have specified the configuration details for mapping JMS consumer to IWS web service instead of XAI inbound service. XAI inbound service has been deprecated by Oracle and Inbound Web Service is to be used in latest versions of the product.

Below example is using C2M Application. But the technical configuration is same for all OUAF products.

There is a slight difference in the configuration to be done depending on whether the JMS queue is hosted by the same server as the one hosting the OUAF application or if it is a different/external server. Have highlighted both of them in the sections below.

Local JMS queue

For Local JMS queue, JMS queue is present on the same weblogic server as that on which OUAF application is hosted

First step is the configuration include files. For IWS, these three config files are to be created.

The name of the files should be same as below except the highlighted prefix part (CM)

  • CM_weblogic-ejb-jar.iws.xml.wls.jms.include

  • CM_ejb-jar.iws.xml.wls.jms_1.include

  • CM_ejb-jar.iws.xml.wls.jms_2.include


File Name

CM_weblogic-ejb-jar.iws.xml.wls.jms.include

File Content

<weblogic-enterprise-bean>

    <ejb-name>DestinationQueueWatch-CM</ejb-name>

    <message-driven-descriptor>

        <pool>

            <max-beans-in-free-pool>5</max-beans-in-free-pool>

            <initial-beans-in-free-pool>1</initial-beans-in-free-pool>

        </pool>

        <destination-jndi-name>jms/MyQueue</destination-jndi-name>

        <connection-factory-jndi-name>jms/MyConnectionFactory</connection-factory-jndi-name>

    </message-driven-descriptor>

</weblogic-enterprise-bean>


Element details

ejb-name – Custom Name to be used. This is common in the three files and connects the configuration together

max-beans-in-free-pool – Defines how many consumers to be activated in parallel. This defines how many message can be consumed in parallel by the server. You can increase or decrease per need.

destination-jndi-name – This is the local JNDI name of the queue. In case of foreign JMS queue, it is the local jndi name of the foreign queue.

connection-factory-jndi-name – This is the local JNDI name of the connection factory. In case of foreign JMS queue, it is the local jndi name of the foreign connection factory.



File Name

CM_ejb-jar.iws.xml.wls.jms_1.include

File Content

    <message-driven>

      <description>MDB for DestinationQueue-CM</description>

      <display-name>DestinationQueueWatcher-CM</display-name>

      <ejb-name>DestinationQueueWatch-CM</ejb-name>

      <ejb-class>com.oracle.ouaf.ws.mdb.MessageProcessor</ejb-class>

      <messaging-type>javax.jms.MessageListener</messaging-type>

      <transaction-type>Bean</transaction-type>

      <message-destination-type>javax.jms.Queue</message-destination-type>

      <env-entry>

         <description>Allow messages without 'SOAPJMS_targetService' set</description>

         <env-entry-name>xaiCompatible</env-entry-name>

         <env-entry-type>java.lang.Boolean</env-entry-type>

         <env-entry-value>true</env-entry-value>

      </env-entry>

      <env-entry>

         <description>user name case insensitive</description>

         <env-entry-name>caseInsensitiveName</env-entry-name>

         <env-entry-type>java.lang.Boolean</env-entry-type>

         <env-entry-value>true</env-entry-value>

      </env-entry>

      <security-identity>

         <run-as>

                 <role-name>cisusers</role-name>

         </run-as>

      </security-identity>

    </message-driven>

Element details

ejb-name - Custom Name to be used. This is same as that specified in CM_weblogic-ejb-jar.iws.xml.wls.jms.include file

ejb-class – This is the class that differentiates the which service is hit in OUAF framework. This class calls the IWS service.


File Name

CM_ejb-jar.iws.xml.wls.jms_2.include

File Content

<assembly-descriptor>

    <container-transaction>

        <method>

            <ejb-name>DestinationQueueWatch-CM</ejb-name>

            <method-name>onMessage</method-name>

        </method>

        <trans-attribute>NotSupported</trans-attribute>

    </container-transaction>

</assembly-descriptor>

Element details

ejb-name - Custom Name to be used. This is same as that specified in CM_weblogic-ejb-jar.iws.xml.wls.jms.include file



Once this configuration is done place the three files in the following folder:

%SPLBASE%\templates

Navigate to %SPLBASE%\bin and

Run initialSetup.cmd

Once initialSetup is completed, you can verify that the file content has been included in the config files at following location:

%SPLBASE%\splapp\iws\resources

Verify that weblogic-ejb-jar.xml and ejb-jar.xml are updated with the include file content.

Once done, start the Application server from weblogic front end




Once server is started

Run iwsdeploy.cmd

(This step assumes that IWS has already been deployed before on the server. If not refer the application installation document and refer the steps for first time deployment of IWS)

Verify IWS is deployed successfully.

Navigate to the JMS Module and open the JMS queue.


As seen below the consumers current count is 5. This means the consumers are attached on the JMS queue and ready for consuming.


Below diagram shows a schematic representation of above configuration


External JMS queue

For External JMS queue, JMS queue is present on either different server, on the same local weblogic instance or external weblogic/nonweblogic server.

For pointing to external queue (either different server on same local weblogic instance or external weblogic/nonweblogic server), following configuration is needed.

Create a foreign server in the C2M server instance. Use a JMS module that is present on the local weblogic server.


Select the same server as the one in which C2M application is hosted

As seen below Foreign Server has been created


Navigate to the Foreign Server-> Configuration -> General

JNDI Initial Context Factory: Set to the context factory to be used for the external server. If external server is Weblogic, use weblogic.jndi.WLInitialContextFactory

JNDI Connection URL: JNDI URL of external server

JNDI Properties Credential: In case authentication is needed for external server, populate the JNDI properties Credential with the password.

JNDI Properties: JNDI properties is to be populated with user name in following way

java.naming.security.principal=remote_domain_username


Navigate to the Foreign Server-> Configuration -> Destinations

Create a new Destination

Name: Any custom name

Local JNDI name: Custom JNDI local name for queue. This is the name that is to be configured in the file CM_weblogic-ejb-jar.iws.xml.wls.jms.include in ‘destination-jndi-name’ element

Remote JNDI Name: This is the JNDI name of the queue in the external server

Save the configuration, as seen below the Destination is created.

Next navigate to Foreign Server-> Configuration -> Connection Factories

Name: Any custom name

Local JNDI name: Custom JNDI local name for connection factory. This is the name that is to be configured in the file CM_weblogic-ejb-jar.iws.xml.wls.jms.include in connection-factory-jndi-name element

Remote JNDI Name: This is the JNDI name of the queue in the external server

Save the configuration, as seen below the Connection factory is created.


Once this configuration is done, rest of the steps are same as for local queue.

Update CM_weblogic-ejb-jar.iws.xml.wls.jms.include with local JNDI names of queue and connection factory.

CM_weblogic-ejb-jar.iws.xml.wls.jms.include

File Content

<weblogic-enterprise-bean>

    <ejb-name>DestinationQueueWatch-CM</ejb-name>

    <message-driven-descriptor>

        <pool>

            <max-beans-in-free-pool>5</max-beans-in-free-pool>

            <initial-beans-in-free-pool>1</initial-beans-in-free-pool>

        </pool>

        <destination-jndi-name>jms/MyForeignQueue</destination-jndi-name>

        <connection-factory-jndi-name>jms/MyForeignConnectionFactory</connection-factory-jndi-name>

    </message-driven-descriptor>

</weblogic-enterprise-bean>



Rest of the configuration of the three files is same as that for local JMS queue.

Once this configuration is done place the three files in the following folder:

%SPLBASE%\templates

Navigate to %SPLBASE%\bin and 

Run initialSetup.cmd

Once done, start the Application server from weblogic front end


Once server is started

Run iwsdeploy.cmd

(This step assumes that IWS has already been deployed before on the server. If not refer the application installation document and refer the steps for first time deployment of IWS)


Once IWS is successfully deployed, navigate to the external server, open the JMS queue, and verify that the consumers count is non zero

As seen below the JMS queue and connection factory on external server

As seen below the consumers current count is 5. This means the consumers are attached on the JMS queue and ready for consuming.

As seen below the consumers current count is 5. This means the consumers are attached on the JMS queue and ready for consuming. Below diagram shows a representational view of the above configuration.


Testing the JMS queue consumer configuration

Using Device Event Seeder IWS for testing


Device screen showing the device events on a sample device. We will try to add a new device event on this device from JMS queue


Navigate to the JMS queue on Weblogic. Select the queue and click on Show messages

Summary of JMS messages opens up. Click new button.

Produce JMS message screen opens. In the Body field copy the payload message. Below is the JMS payload used, for reference.

JMS Payload

<D1-DeviceEventSeeder>

<externalSenderId>SENSUS</externalSenderId>

<deviceEventType>DEVICELOWBATTERY</deviceEventType>

<eventDateTime>2020-05-29T10:20:15</eventDateTime>

<deviceId>272059640649</deviceId>

</D1-DeviceEventSeeder>


As seen a message is now present in the queue.

Navigate back to the monitoring screen. You can see the messages pending count is 0. That means the message has been consumed. Also message total has increased from 1 to 2.

Navigate back to show messages. As seen no message is present in queue now.

Navigate back to the C2M application device screen. As seen below new device event has been created


Opening the device event. As seen below device event has been successfully creating using JMS queue and JMS consumer configured earlier.

Thus we have successfully configured JMS queue for both internal and external JMS queues. This concludes the JMS consumer configuration for Inbound Web Services. Let me know in case of any queries on the same.

3 comments:

  1. Hi Sreeneeth - This is a really helpful blog, thank you for putting this out in such simple steps. We tried the above steps in our implementation and are encountering the following error message:
    java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[SYSTEM, cisusers, Administrators]
    Can you please advise around this issue? Cross domain security is enabled on both the weblogic domains.

    ReplyDelete
    Replies
    1. Can you let me know where this error is coming up. Is it in the application logs.

      Delete
    2. Hey Sree - Thanks for responding. It is coming in the MDM Server logs.

      Delete

OUAF Oracle Utilities WAM / ODM 2.4.0.0 installation on Windows

  This blog is for anyone looking to install Oracle Utilities WAM or ODM 2.4.0.0 (Oracle Utilities Workflow and Asset Management) or (Orac...