Oracle JMS Key Concepts 2

HermesJMS setup – Connecting to Oracle AQ JMS using WLS foreign server

 

In this scenario a HermesJMS client will connect to the Oracle AQ JMS using WebLogic (WLS) resources.
Internally to HermesJMS, the ConnectionFactory and Destinations will be obtained by using the JNDI resources from WLS.

Pre-requisites

  • RIB is installed (meaning the desired Topics and permissions are created in the Oracle AQ JMS Database)
  • WebLogic Sever is available (RIB Domain can be used)
  • Hermes JMS is installed in the OS (Windows/Unix)
    • A good option is to install SoapUI 5.4 which will include HermesJMS as part of its bundle
  • The OS CLASS_PATH points to the intended JRE (e.g.: C:\Program Files\Java\jre1.8.0_131 )
  • The following LIBs are available
    • jar (must be taken from the AQ Database Server under ORACLE_HOME/rdbms/jlib)
    • 7.jar (must be taken from the AQ Database Server under ORACLE_HOME/jdbc/lib)
    • jar (available in WebLogic) (other libs can be used – refer to the Admin JMS Resources in WLS documentation)

 

STEP 1 Configure JMS Foreign Server in WLS to expose Oracle AQ JMS

The instructions below will provide guidance on how to create a new JMS Foreign Server pointing to an  Oracle DB AQ. This will allow internal and stand-alone applications to use the servers JNDI to lookup for  Connection Factories and Destinations.

The Database connection needs to be setup in different manners depending on the type of clients which

will use the WLS resources.

  • If internal client, then a DataSource must be created in WebLogic and used as part of the Foreign Server Setup.
  • If an external Stand-Alone client needs to connect, then no DataSource is required to be configured in WLS and the
  • JDBC URL must be defined as part of the Foreign Server setup.
  • Both of the approaches are detailed in the next slides. Still it is important to mention that when using
  • HermesJMS, the Foreign Server setup must use the JDBC URL configuration.

Press Next.

Select “ThinXA for Instance Connections”  Press Next.

Press Next (Transaction Options – Nothing to define).

 

  • Creating a new DataSource (not required for Stand-Alone external clients)

Fill in the values:

Database Name:<AQ database name for the specific Env – Use DB Service Name>

Host Name: <AQ database host for the specific Env>

Port: <Used port> E.g. 1740

Database User Name: RIBAQ

Password: <AQ database password for the specific Env>

Confirm Password: <AQ database password for the specific Env>  Press Next.

Confirm the URL uses “/” instead of “:” before the Service Name.

  • Creating a new DataSource (not required for Stand-Alone external clients)

Press Test Configuration

Targets: Select all the servers or clusters  Press Finish.

Apply the changes.

  • Creating a new JMS Module

Do “Lock & Edit”.  Create JMS Modules.

Go to Home -> Services -> Messaging -> JMS Modules (if not already there)

Press New to create the following JMS Modules

Name: RibAqJmsModule

Press Next.

Select all the Servers.  Press Next.

Press Finish.

Apply the changes.

  • Create JMS Foreign Server for AQ

Do “Lock & Edit”.

Go to Home > Services > Messaging > JMS Modules > RibAqJmsModule (the Module created in the previous step)

Press New > Select “Foreign Server” > Name: RibAqJmsForeignServer > Finish

 

  • Option 1) Create JMS Foreign Server for AQ (Using DataSource)

Go to Home > Services > Messaging > JMS Modules > RibAqJmsModule > RibAqJmsForeignServer > Select Tab “General” and  then add:

JNDI Initial Context Factory: oracle.jms.AQjmsInitialContextFactory

Clear fields JNDI connection url and credentials

JNDI Properties: datasource=jdbc/RibAqJmsDataSource

 

  • Option 2) Create JMS Foreign Server for AQ (Using JDBC URL) – This was the configuration used for POC.

Go to Home > Services > Messaging > JMS Modules > RibAqJmsModule > RibAqJmsForeignServer > Select Tab “General” and  then add:

  • JNDI Initial Context Factory: oracle.jms.AQjmsInitialContextFactory
  • Clear field JNDI Connection URL
  • JNDI Properties Credentials: <Provide the AQ Database credentials>
  • Confirm JNDI Properties Credentials: <Provide the AQ Database credentials>
  • JNDI Properties: <Provide the following details>
  • java.naming.security.principal=RIBAQ db_url=jdbc:oracle:thin:@******.com:1***0/sv***rib

  • Create JMS Connection factory and Destinations for AQ

Go to Home > Services > Messaging > JMS Modules > RibAqJmsModule > RibAqJmsForeignServer > Select Tab “Configuration”

and under “Connection Factories” > New:

Name:  RibAqJmsXATopicConnectionFactoryForeignCF  Local JNDI Name: jms/RibAqJmsXATopicConnectionFactory  Remote JNDI Name: XATopicConnectionFactory

  • Create JMS Connection factory and Destinations for AQ

Go to Home > Services > Messaging > JMS Modules > RibAqJmsModule > RibAqJmsForeignServer > Select Tab “Configuration”

and under “Destinations” > New:

Name:  <Provide a meaningful name for the Destination>

Local JNDI Name: <Provide a meaningful local name for the Destination. It will be object name in the JNDI tree>

Remote JNDI Name: <Provide the exact name of the Destination in the AQ JMS Database. If the destination is a Topic then

its required to precede the Topic name by “Topics/” else, the target is Queue and must be preceded by “Queues/”>

 

STEP 2 Create a new jms session under HermesJMS

  • Expand the “jms” tree
  • Right click “sessions” and select “New session

  • In the Preferences window that appears (by default you should be in tab “Sessions”)
    • Under section “Session” provide a meaningfull name (e.g. “FS test”)
    • Under section “Plug In” leave the default value “Default

  • In the Preferences window click tab “Providers
  • Under “ClasspathGroups” create a new Group (right click and select “Add Group”)
  • Provide a meaningfull name (e.g. “Test”)

  • In the Preferences window click tab “Providers
  • Under “Library” add the following JAR(s) by right clicking and selecting “Add JAR(s)”
  • wlthint3client.jar, aqapi.jar , ojdbc7.jar(when addign this library click “Don’t Scan the JAR(s) for JMS Connection Factories in the dialog box that appears”)

  • Click “Apply” Button
  • In the Preferences window click and change to tab “Sessions
  • Execute the next steps in the following order:
  • Under section “Connection Factory
  • Select Loader as the name given to the new Group in the tab “ClasspathGroups”. In this example named as “Test
  • Select “Class” as “hermes.JNDIConnectionFactory” from the drop down list;
  • Under section “Plug In” select from the list “BEA WebLogic

  • In the Preferences window tab “Sessions
  • Under section “Connection Factory” in the Property table add the following properties and values
  • binding: [JNDI for the connection_factory – needs to be the name defined in WLS when setting up the Foreign server]

E.g.: jms/RibAqJmsXATopicConnectionFactory

  • initialContextFactory: weblogic.jndi.WLInitialContextFactory
  • providerURL: t3://[host]:[port] E.g.: t3://d***2:7**5
  • securityPrincipal: [WLS username]
  • securityCredentials: [WLS password]
  • Click “Apply” Button. At this stage the HermesJMS setup for connecting to AQ JMS is completed

 

STEP 3 Find Destinations Automatically

  • Having the new JMS Session created in HermesJMS (in this sample named as “FS test”) its possible to  automatically discover the available Queues and Topics
  • Select the FS test session, right click and choose the Discover… option
  • A new dialog box will appear detailing how many destinations have been found. Add to the current set  of destinations (which at the time the HermesJMS session was created was empty)
  • In this approach the Destination types are not identified. Its manually required to identify its specie
  • (Topic/Queue).

 

STEP 4 Manually add Destinations (Optional)

Its possible to add manually JMS Destinations (instead off adding them automatically by using  HermesJMS functionality Discover).

  • In jms sessions tree, right click the session “FS test”. From the menu that appears select New > Add  topic.
  • Provide the below information:
    • Name: <name registered in the JNDI tree for the Destination. E.g.: jms/etEXTVendor>
    • Domain: <TOPIC or QUEUE>
    • Durable: <Boolean indicating if the Subscriber created when connecting to the Topic should be Durable>
    • DurableName: <Name used when creating a Durable Subscriber>

 

STEP 5 Browse the Destination / Open a Message

In order to browse messages in a specific Topic HermesJMS creates a session to that particular topic and  creates at that time a subscriber (if non-durable). From this point onwards an user can consume messages  and publish messages from/to that Topic.

It is important to mention that when looking to Destinations from JNDI tree in automated manner,  HermesJMS is not able to identify if the resource is a Topic or a Queue. So this must be manually edited in  the Destination.

  • To edit an existing Destination, in jms sessions tree, right click the session “FS test”. From the menu that  appears select Edit.
  • You can edit the below information:
    • Name: <name registered in the JNDI tree for the Destination. E.g.: jms/etEXTVendor>
    • Domain: <TOPIC or QUEUE>
    • Durable: <Boolean indicating if the Subscriber created when the connecting to the Topic should be Durable>
    • DurableName: <Name used when creating a Durable Subscriber>
  • Once the Destination domain is identified it can be accessed. In the scope of this POC, only Topics have  been accessed – so the few used have been setup as Non-Durable Topics.
  • To connect to the Topic and start to receive messages, right click in the desired Topic under the session  “FS test” and select “Browse…”. The following image shows some data being accessed in customer env.

 

STEP 6 What is happening behind

In this approach, WebLogic was used to expose the AQ JMS as a Foreign Server. Its outcome is the  creation of JNDIs defining the ConnectionFactory and Destinations.

  • To resolve the JNDI Weblogic must be capable of connecting to the AQ JMS. It achieves this as long as  the Foreign Server is properly setup to connect to the Database (using JDBC URL in this case). This is  important to retain wich relates the last point covered in this deck – Challenge.
  • HermesJMS is configured to connect to the WLS Server where the Foreign Server is deployed and  lookup for the ConnectionFactory resource in the JNDI tree.
  • The ConnectionFactory resource is given to HermesJMS and references objects only known under the  Oracle JMS API (aqapi.jar). This is the reason why it needs to be added to the classpath (along with  some other libs).

  • HermesJMS establishes the connection to the

AQ JMS Database with the ConnectionFactory details.

  • Once the Destinations are identified (also by looking into the  WLS JNDI tree, a new session can be opened and messages  Consumed or Published.
  • Concepts of Durable Subscriber and Non-Durable Subscriber  must be known but are not under the scope of this POC  which simply used Non-Durable Subscribers.
  • The diagram in the right demonstrates the architecture.