Wednesday Jan 02, 2013

JMS Step 8 - How to Read from an AQ JMS (Advanced Queueing JMS) from a BPEL Process

JMS Step 8 - How to Read from an AQ JMS (Advanced Queueing JMS) from a BPEL Process

Welcome to the last post in the series of JMS articles on using JMS queues from within SOA. The previous posts were:

  1. JMS Step 1 - How to Create a Simple JMS Queue in Weblogic Server 11g
  2. JMS Step 2 - Using the QueueSend.java Sample Program to Send a Message to a JMS Queue
  3. JMS Step 3 - Using the QueueReceive.java Sample Program to Read a Message from a JMS Queue
  4. JMS Step 4 - How to Create an 11g BPEL Process Which Writes a Message Based on an XML Schema to a JMS Queue
  5. JMS Step 5 - How to Create an 11g BPEL Process Which Reads a Message Based on an XML Schema from a JMS Queue
  6. JMS Step 6 - How to Set Up an AQ JMS (Advanced Queueing JMS) for SOA Purposes
  7. JMS Step 7 - How to Write to an AQ JMS (Advanced Queueing JMS) Queue from a BPEL Process

This example demonstrates how to read a simple message from an Oracle AQ via the WebLogic AQ JMS functionality from a BPEL process and a JMS adapter. It is part of a step-by-step series of samples. If you have not yet reviewed the previous posts, please do so first, as this one references objects created created there.

1. Recap and Prerequisites

In the last two examples we created an Oracle Advanced Queue (AQ) some related JMS objects in WebLogic Server, which allow us to be able to access it via JMS. Here are the objects which were created and their names and JNDI names:

Database Objects

Name

Type

AQJMSUSER

Database User

MyQueueTable

Advanced Queue (AQ) Table

UserQueue

Advanced Queue

WebLogic Server Objects

Object Name

Type

JNDI Name

aqjmsuserDataSource

Data Source

jdbc/aqjmsuserDataSource

AqJmsModule

JMS System Module

AqJmsForeignServer

JMS Foreign Server

AqJmsForeignServerConnectionFactory

JMS Foreign Server Connection Factory

AqJmsForeignServerConnectionFactory

AqJmsForeignDestination

AQ JMS Foreign Destination

queue/USERQUEUE

eis/aqjms/UserQueue

Connection Pool

eis/aqjms/UserQueue

In the example JMS Step 7 - How To Write To an AQ JMS Queue From a BPEL Process  we wrote a simple message to that queue. In this example, we will create a composite with a BPEL process, which reads the same message from the AQ JMS using a JMS adapter.

2 . Create a BPEL Composite with a JMS Adapter Partner Link

This step requires that you have a valid Application Server Connection defined in JDeveloper, pointing to the application server on which you created the JMS Queue and Connection Factory. You can create this connection in JDeveloper under the Application Server Navigator. Give it any name and be sure to test the connection before completing it.

This sample will read a simple XML message from the AQ JMS queue via the JMS adapter, based on the following XSD file, which consists of a single string element. A message based on this XSD was written to the queue in the previous example.

stringPayload.xsd

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns="http://www.example.org"
               targetNamespace="http://www.example.org"
               elementFormDefault="qualified">
 <xsd:element name="exampleElement" type="xsd:string">
 </xsd:element>
</xsd:schema>

The following steps are all executed in JDeveloper. The SOA project will be created inside a JDeveloper Application. If you do not already have an application to contain the project, you can create a new one via File > New > General > Generic Application. Give the application any name, for example JMSTests and, when prompted for a project name and type, call the project   JmsAdapterReadAqJms  and select SOA as the project technology type. If you already have an application, continue below.

Create a SOA Project

Create a new project and select SOA Tier > SOA Project as its type. Name it JmsAdapterReadAqJms . When prompted for the composite type, choose Empty Composite.

Create a JMS Adapter Partner Link

In the composite editor, drag a JMS adapter over from the Component Palette to the left-hand swim lane, under Exposed Services.

This will start the JMS Adapter Configuration Wizard. Use the following entries:

Service Name: JmsAdapterRead
Oracle Enterprise Messaging Service (OEMS): Oracle Advanced Queueing
AppServer Connection: Use an existing application server connection pointing to the WebLogic server on which the connection factory created earlier is located. You can use the “+” button to create a connection directly from the wizard, if you do not already have one.

Adapter Interface > Interface: Define from operation and schema (specified later)

Operation Type: Consume Message
Operation Name: Consume_message

Consume Operation Parameters

Destination Name: Wait for the list to populate. (Only foreign servers are listed here, because Oracle Advanced Queuing was selected earlier, in step 3) .

        Select the foreign server destination created earlier,

AqJmsForeignDestination (queue) .

This will automatically populate the Destination Name field with the name of the foreign destination, queue/USERQUEUE .

JNDI Name: The JNDI name to use for the JMS connection. This is the JNDI name of the connection pool created in the WebLogic Server. JDeveloper does not verify the value entered here. If you enter a wrong value, the JMS adapter won’t find the queue and you will get an error message at runtime. In our example, this is the value eis/aqjms/UserQueue .

Messages

URL: We will use the XSD file created during the previous examples, e.g. the JmsAdapterWriteSchema or JmsAdapterWriteAqJms projects to define the format for the incoming message payload and, at the same time, demonstrate how to import an existing XSD file into a JDeveloper project.

Press the magnifying glass icon to search for schema files. In the Type Chooser, press the Import Schema File button.


Select the next magnifying glass next to URL to search for schema files. Navigate to the location of the JmsAdapterWriteSchema or JmsAdapterWriteAqJms projects > xsd and select the stringPayload.xsd file.

Check the “Copy to Project” checkbox, press OK and confirm the following Localize Files popup.

Now that the XSD file has been copied to the local project, it can be selected from the project’s schema files. Expand Project Schema Files > stringPayload.xsd and select exampleElement : string .

Press Next and Finish, which will complete the JMS Adapter configuration.
Save the project.

Create a BPEL Component

Drag a BPEL Process from the Component Palette (Service Components) to the Components section of the composite designer. Name it JmsAdapterReadAqJms  and select Template: Define Service Later and press OK.

Wire the JMS Adapter to the BPEL Component

Now wire the JMS adapter to the BPEL process, by dragging the arrow from the adapter to the BPEL process. A Transaction Properties popup will be displayed. Set the delivery mode to async.persist.

This completes the steps at the composite level.


3. Complete the BPEL Process Design

Invoke the BPEL Flow via the JMS Adapter

Open the BPEL component by double-clicking it in the design view of the composite.xml, or open it from the project navigator by selecting the JmsAdapterReadAqJms.bpel file. This will display the BPEL process in the design view. You should see the JmsAdapterRead partner link in the left-hand swim lane.

Drag a Receive activity onto the BPEL flow diagram, then drag a wire (left-hand yellow arrow) from it to the JMS adapter. This will open the Receive activity editor. Auto-generate the variable by pressing the green “+” button and check the “Create Instance” checkbox. This will result in a BPEL instance being created when a new JMS message is received.

At this point the composite can be deployed and it will pick up any messages from the AQ JMS queue. This is very rudimentary, but is sufficient for our demonstration purposes as we will see in the next step.

As with the previous examples, you can extend the BPEL process to do something useful with the message, such as pass it to another web service, write it to a file using a file adapter or to a database via a database adapter. Also see JMS Step 5 - How To Create an 11g BPEL Process Which Reads a Message Based on an XML Schema from a JMS Queue  for an example of how to add a Java Embedding activity to the process to print the message to standard output.


4. Test the Composite

Execute an instance of the previous example JmsAdapterWriteAqJms  which will write a message to the AQ called UserQueue, if you have not yet done so. That example also explains how to view and monitor the queue from SQL*Plus or JDeveloper. You should see a message similar to the following in the queue:

Now compile and deploy the composite JmsAdapterReadAqJms. It will immediately begin dequeuing messages from the AQ. Requery the queue to confirm that the message has been dequeued. Then, in Enterprise Manager 11g Fusion Middleware Control (EM), navigate to SOA > soa-infra (soa_server1) > default (or wherever you deployed your composite) and click on  JmsAdapterReadAqJms [1.0] . You should see an instance ID listed under Recent Instances. Select it, to view its flow trace, then select the JmsAdapterReadAqJms BPEL Component.

This should display the Audit Trail, including the successful Receive activity. Click on “View XML Document” to see the dequeued message.

This concludes this example and the SOA/JMS series.

Please make use of the comments section for your feedback and questions. If there is enough interest, I will plan to do a series of webcasts to go over and demonstrate the samples shown here.


Thanks-you

John-Brown Evans
Senior Principal Support Engineer
Oracle Technology Proactive Support Delivery

Wednesday Dec 19, 2012

JMS Step 7 - How to Write to an AQ JMS (Advanced Queueing JMS) Queue from a BPEL Process

JMS Step 7 - How to Write to an AQ JMS (Advanced Queueing JMS) Queue from a BPEL Process

This post continues the series of JMS articles which demonstrate how to use JMS queues in a SOA context. The previous posts were:

  1. JMS Step 1 - How to Create a Simple JMS Queue in Weblogic Server 11g
  2. JMS Step 2 - Using the QueueSend.java Sample Program to Send a Message to a JMS Queue
  3. JMS Step 3 - Using the QueueReceive.java Sample Program to Read a Message from a JMS Queue
  4. JMS Step 4 - How to Create an 11g BPEL Process Which Writes a Message Based on an XML Schema to a JMS Queue
  5. JMS Step 5 - How to Create an 11g BPEL Process Which Reads a Message Based on an XML Schema from a JMS Queue
  6. JMS Step 6 - How to Set Up an AQ JMS (Advanced Queueing JMS) for SOA Purposes

This example demonstrates how to write a simple message to an Oracle AQ via the the WebLogic AQ JMS functionality from a BPEL process and a JMS adapter. If you have not yet reviewed the previous posts, please do so first, especially the JMS Step 6 post, as this one references objects created there.

1. Recap and Prerequisites

In the previous example, we created an Oracle Advanced Queue (AQ) and some related JMS objects in WebLogic Server to be able to access it via JMS. Here are the objects which were created and their names and JNDI names:

Database Objects

Name

Type

AQJMSUSER

Database User

MyQueueTable

Advanced Queue (AQ) Table

UserQueue

Advanced Queue

WebLogic Server Objects

Object Name

Type

JNDI Name

aqjmsuserDataSource

Data Source

jdbc/aqjmsuserDataSource

AqJmsModule

JMS System Module

AqJmsForeignServer

JMS Foreign Server

AqJmsForeignServerConnectionFactory

JMS Foreign Server Connection Factory

AqJmsForeignServerConnectionFactory

AqJmsForeignDestination

AQ JMS Foreign Destination

queue/USERQUEUE

eis/aqjms/UserQueue

Connection Pool

eis/aqjms/UserQueue

2 . Create a BPEL Composite with a JMS Adapter Partner Link

This step requires that you have a valid Application Server Connection defined in JDeveloper, pointing to the application server on which you created the JMS Queue and Connection Factory. You can create this connection in JDeveloper under the Application Server Navigator. Give it any name and be sure to test the connection before completing it.

This sample will write a simple XML message to the AQ JMS queue via the JMS adapter, based on the following XSD file, which consists of a single string element:

stringPayload.xsd

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns="http://www.example.org"
               targetNamespace="http://www.example.org"
               elementFormDefault="qualified">
 <xsd:element name="exampleElement" type="xsd:string">
 </xsd:element>
</xsd:schema>

The following steps are all executed in JDeveloper. The SOA project will be created inside a JDeveloper Application. If you do not already have an application to contain the project, you can create a new one via File > New > General > Generic Application. Give the application any name, for example JMSTests and, when prompted for a project name and type, call the project   JmsAdapterWriteAqJms  and select SOA as the project technology type. If you already have an application, continue below.

Create a SOA Project

Create a new project and select SOA Tier > SOA Project as its type. Name it JmsAdapterWriteAqJms . When prompted for the composite type, choose Composite With BPEL Process.

When prompted for the BPEL Process, name it JmsAdapterWriteAqJms too and choose Synchronous BPEL Process as the template.
This will create a composite with a BPEL process and an exposed SOAP service. Double-click the BPEL process to open and begin editing it. You should see a simple BPEL process with a Receive and Reply activity. As we created a default process without an XML schema, the input and output variables are simple strings.

Create an XSD File

An XSD file is required later to define the message format to be passed to the JMS adapter. In this step, we create a simple XSD file, containing a string variable and add it to the project.

First select the xsd item in the left-hand navigation tree to ensure that the XSD file is created under that item.

Select File > New > General > XML and choose XML Schema.

Call it stringPayload.xsd  and when the editor opens, select the Source view.

then replace the contents with the contents of the stringPayload.xsd example above and save the file. You should see it under the XSD item in the navigation tree.

Create a JMS Adapter Partner Link

We will create the JMS adapter as a service at the composite level. If it is not already open, double-click the composite.xml file in the navigator to open it.

From the Component Palette, drag a JMS adapter over onto the right-hand swim lane, under External References.

This will start the JMS Adapter Configuration Wizard. Use the following entries:

Service Name: JmsAdapterWrite

Oracle Enterprise Messaging Service (OEMS): Oracle Advanced Queueing

AppServer Connection: Use an existing application server connection pointing to the WebLogic server on which the connection factory created earlier is located. You can use the “+” button to create a connection directly from the wizard, if you do not already have one.

Adapter Interface > Interface: Define from operation and schema (specified later)

Operation Type: Produce Message
Operation Name: Produce_message

Produce Operation Parameters

Destination Name: Wait for the list to populate. (Only foreign servers are listed here, because Oracle Advanced Queuing was selected earlier, in step 3) .

        Select the foreign server destination created earlier,

AqJmsForeignDestination (queue) .

This will automatically populate the Destination Name field with the name of the foreign destination, queue/USERQUEUE .

JNDI Name: The JNDI name to use for the JMS connection. This is the JNDI name of the connection pool created in the WebLogic Server.JDeveloper does not verify the value entered here. If you enter a wrong value, the JMS adapter won’t find the queue and you will get an error message at runtime. In our example, this is the value eis/aqjms/UserQueue

Messages
URL:
We will use the XSD file we created earlier, stringPayload.xsd to define the message format for the JMS adapter. Press the magnifying glass icon to search for schema files. Expand Project Schema Files > stringPayload.xsd and select exampleElement : string .

Press Next and Finish, which will complete the JMS Adapter configuration.

Wire the BPEL Component to the JMS Adapter

In this step, we link the BPEL process/component to the JMS adapter. From the composite.xml editor, drag the right-arrow icon from the BPEL process to the JMS adapter’s in-arrow.

  This completes the steps at the composite level.

3. Complete the BPEL Process Design

Invoke the JMS Adapter

Open the BPEL component by double-clicking it in the design view of the composite.xml. This will display the BPEL process in the design view. You should see the JmsAdapterWrite partner link under one of the two swim lanes. We want it in the right-hand swim lane. If JDeveloper displays it in the left-hand lane, right-click it and choose Display > Move To Opposite Swim Lane.

An Invoke activity is required in order to invoke the JMS adapter. Drag an Invoke activity between the Receive and Reply activities. Drag the right-hand arrow from the Invoke activity to the JMS adapter partner link. This will open the Invoke editor. The correct default values are entered automatically and are fine for our purposes. We only need to define the input variable to use for the JMS adapter. By pressing the green “+” symbol, a variable of the correct type can be auto-generated, for example with the name Invoke1_Produce_Message_InputVariable.

Press OK after creating the variable.

Assign Variables

Drag an Assign activity between the Receive and Invoke activities. We will simply copy the input variable to the JMS adapter and, for completion, so the process has an output to print, again to the process’s output variable.

Double-click the Assign activity and create two Copy rules:

for the first, drag Variables > inputVariable > payload > client:process > client:input_string to Invoke1_Produce_Message_InputVariable > body > ns2:exampleElement

for the second, drag the same input variable to outputVariable > payload > client:processResponse > client:result

This will create two copy rules, similar to the following:

Press OK.

This completes the BPEL and Composite design.

4. Compile and Deploy the Composite

Compile the process by pressing the Make or Rebuild icons or by right-clicking the project name in the navigator and selecting Make... or Rebuild...

If the compilation is successful, deploy it to the SOA server connection defined earlier. (Right-click the project name in the navigator, select Deploy to Application Server, choose the application server connection, choose the partition on the server (usually default) and press Finish. You should see the message

----  Deployment finished.  ----


in the Deployment frame, if the deployment was successful.

5. Test the Composite

Execute a Test Instance

In a browser, log in to the Enterprise Manager 11g Fusion Middleware Control (EM) for your SOA installation. Navigate to SOA > soa-infra (soa_server1) > default (or wherever you deployed your composite) and click on  JmsAdapterWriteAqJms [1.0] , then press the Test button. Enter any string into the text input field, for example “Test message from JmsAdapterWriteAqJms” then press Test Web Service.

If the instance is successful, you should see the same text you entered in the Response payload frame.

Monitor the Advanced Queue

The test message will be written to the advanced queue created at the top of this sample. To confirm it, log in to the database as AQJMSUSER and query the MYQUEUETABLE database table. For example, from a shell window with SQL*Plus

sqlplus aqjmsuser/aqjmsuser

SQL> SELECT user_data FROM myqueuetable;

which will display the message contents, for example

Similarly, you can use the JDeveloper Database Navigator to view the contents. Use a database connection to the AQJMSUSER and in the navigator, expand Queues Tables and select MYQUEUETABLE. Select the Data tab and scroll to the USER_DATA column to view its contents.

This concludes this example.

The following post will be the last one in this series. In it, we will learn how to read the message we just wrote using a BPEL process and AQ JMS.

Best regards
John-Brown Evans
Oracle Technology Proactive Support Delivery

Wednesday Dec 12, 2012

JMS Step 6 - How to Set Up an AQ JMS (Advanced Queueing JMS) for SOA Purposes

JMS Step 6 - How to Set Up an AQ JMS (Advanced Queueing JMS) for SOA Purposes

This post continues the series of JMS articles which demonstrate how to use JMS queues in a SOA context. The previous posts were:

  1. JMS Step 1 - How to Create a Simple JMS Queue in Weblogic Server 11g
  2. JMS Step 2 - Using the QueueSend.java Sample Program to Send a Message to a JMS Queue
  3. JMS Step 3 - Using the QueueReceive.java Sample Program to Read a Message from a JMS Queue
  4. JMS Step 4 - How to Create an 11g BPEL Process Which Writes a Message Based on an XML Schema to a JMS Queue
  5. JMS Step 5 - How to Create an 11g BPEL Process Which Reads a Message Based on an XML Schema from a JMS Queue

This example leads you through the creation of an Oracle database Advanced Queue and the related WebLogic server objects in order to use AQ JMS in connection with a SOA composite. If you have not already done so, I recommend you look at the previous posts in this series, as they include steps which this example builds upon.

The following examples will demonstrate how to write and read from the queue from a SOA process.

1. Recap and Prerequisites

In the previous examples, we created a JMS Queue, a Connection Factory and a Connection Pool in the WebLogic Server Console. Then we wrote and deployed BPEL composites, which enqueued and dequeued a simple XML payload.

AQ JMS allows you to interoperate with database Advanced Queueing via JMS in WebLogic server and therefore take advantage of database features, while maintaining compliance with the JMS architecture. AQ JMS uses the WebLogic JMS Foreign Server framework. A full description of this functionality can be found in the following Oracle documentation

Oracle® Fusion Middleware Configuring and Managing JMS for Oracle WebLogic Server
11g Release 1 (10.3.6)
Part Number E13738-06
7. Interoperating with Oracle AQ JMS
http://docs.oracle.com/cd/E23943_01/web.1111/e13738/aq_jms.htm#CJACBCEJ

For easier reference, this sample will use the same names for the objects as in the above document, except for the name of the database user, as it is possible that this user already exists in your database. We will create the following objects

Database Objects

Name

Type

AQJMSUSER

Database User

MyQueueTable

Advanced Queue (AQ) Table

UserQueue

Advanced Queue

WebLogic Server Objects

Object Name

Type

JNDI Name

aqjmsuserDataSource

Data Source

jdbc/aqjmsuserDataSource

AqJmsModule

JMS System Module

AqJmsForeignServer

JMS Foreign Server

AqJmsForeignServerConnectionFactory

JMS Foreign Server Connection Factory

AqJmsForeignServerConnectionFactory

AqJmsForeignDestination

AQ JMS Foreign Destination

queue/USERQUEUE

eis/aqjms/UserQueue

Connection Pool

eis/aqjms/UserQueue

2. Create a Database User and Advanced Queue

The following steps can be executed in the database client of your choice, e.g. JDeveloper or SQL Developer. The examples below use SQL*Plus.

Log in to the database as a DBA user, for example SYSTEM or SYS. Create the AQJMSUSER user and grant privileges to enable the user to create AQ objects.

Create Database User and Grant AQ Privileges

sqlplus system/password as SYSDBA
	      
GRANT connect, resource TO aqjmsuser IDENTIFIED BY aqjmsuser;
GRANT aq_user_role TO aqjmsuser;
GRANT execute ON sys.dbms_aqadm TO aqjmsuser;
GRANT execute ON sys.dbms_aq TO aqjmsuser;
GRANT execute ON sys.dbms_aqin TO aqjmsuser;
GRANT execute ON sys.dbms_aqjms TO aqjmsuser;

Create the Queue Table and Advanced Queue and Start the AQ

The following commands are executed as the aqjmsuser database user.

Create the Queue Table

connect aqjmsuser/aqjmsuser;
BEGIN
dbms_aqadm.create_queue_table (
queue_table => 'myQueueTable',
queue_payload_type => 'sys.aq$_jms_text_message',
multiple_consumers => false
);
END;
/

Create the AQ

BEGIN
dbms_aqadm.create_queue (
queue_name => 'userQueue',
queue_table => 'myQueueTable'
);
END;
/

Start the AQ

BEGIN
dbms_aqadm.start_queue (
queue_name => 'userQueue');
END;
/

The above commands can be executed in a single PL/SQL block, but are shown as separate blocks in this example for ease of reference.

You can verify the queue by executing the SQL command

SELECT object_name, object_type FROM user_objects;

which should display the following objects:

OBJECT_NAME                        OBJECT_TYPE
------------------------------ ------------------- 
SYS_C0056513                       INDEX 
SYS_LOB0000170822C00041$$          LOB 
SYS_LOB0000170822C00040$$          LOB 
SYS_LOB0000170822C00037$$          LOB 
AQ$_MYQUEUETABLE_T                 INDEX 
AQ$_MYQUEUETABLE_I                 INDEX 
AQ$_MYQUEUETABLE_E                 QUEUE 
AQ$_MYQUEUETABLE_F                 VIEW 
AQ$MYQUEUETABLE                    VIEW 
MYQUEUETABLE                       TABLE 
USERQUEUE                          QUEUE

Similarly, you can view the objects in JDeveloper via a Database Connection to the AQJMSUSER.

3. Configure WebLogic Server and Add JMS Objects

All these steps are executed from the WebLogic Server Administration Console. Log in as the webLogic user.

Configure a WebLogic Data Source

The data source is required for the database connection to the AQ created above.

Navigate to domain > Services > Data Sources and press New then Generic Data Source.

Use the values:
Name:
aqjmsuserDataSource
JNDI Name:
jdbc/aqjmsuserDataSource

Database type: Oracle

Database Driver: *Oracle’ Driver (Thin XA) for Instance connections; Versions:9.0.1 and later

Connection Properties: Enter the connection information to the database containing the AQ created above and enter aqjmsuser for the User Name and Password.

Press Test Configuration to verify the connection details and press Next.

Target the data source to the soa server.

The data source will be displayed in the list.

It is a good idea to test the data source at this stage. Click on aqjmsuserDataSource, select Monitoring > Testing > soa_server1 and press Test Data Source. The result is displayed at the top of the page.

Configure a JMS System Module

The JMS system module is required to host the JMS foreign server for AQ resources.

Navigate to Services > Messaging > JMS Modules and select New.

Use the values:

Name: AqJmsModule

(Leave Descriptor File Name and Location in Domain empty.)
Target: soa_server1

Click Finish. The other resources will be created in separate steps.

The module will be displayed in the list.

 

Configure a JMS Foreign Server

A foreign server is required in order to reference a 3rd-party JMS provider, in this case the database AQ, within a local WebLogic server JNDI tree.

Navigate to Services > Messaging > JMS Modules and select (click on) AqJmsModule to configure it.

Under Summary of Resources, select New then Foreign Server.

Name: AqJmsForeignServer
Targets: The foreign server is targeted automatically to soa_server1, based on the JMS module’s target.

Press Finish to create the foreign server.

The foreign server resource will be listed in the Summary of Resources for the AqJmsModule, but needs additional configuration steps.

Click on AqJmsForeignServer and select Configuration > General to complete the configuration:

JNDI Initial Context Factory: oracle.jms.AQjmsInitialContextFactory
JNDI Connection URL: <empty>
JNDI Properties Credential:<empty>
Confirm JNDI Properties Credential: <empty>
JNDI Properties:
datasource=jdbc/aqjmsuserDataSource
This is an important property. It is the JNDI name of the data source created above, which points to the AQ schema in the database and must be entered as a name=value pair, as in this example, e.g. datasource=jdbc/aqjmsuserDataSource, including the “datasource=” property name.
Default Targeting Enabled: Leave this value checked.

Press Save to save the configuration.

At this point it is a good idea to verify that the data source was written correctly to the config file. In a terminal window, navigate to $MIDDLEWARE_HOME/user_projects/domains/soa_domain/config/jms  and open the file aqjmsmodule-jms.xml . The foreign server configuration should contain the datasource name-value pair, as follows:

 
<foreign-server name="AqJmsForeignServer">
        <default-targeting-enabled>true</default-targeting-enabled>
        <initial-context-factory>oracle.jms.AQjmsInitialContextFactory</initial-context-factory>
        <jndi-property>
          <key> datasource </key>
          <value> jdbc/aqjmsuserDataSource </value>
        </jndi-property>
  </foreign-server>
</weblogic-jms>

Configure a JMS Foreign Server Connection Factory

When creating the foreign server connection factory, you enter local and remote JNDI names. The name of the connection factory itself and the local JNDI name are arbitrary, but the remote JNDI name must match a specific format, depending on the type of queue or topic to be accessed in the database. This is very important and if the incorrect value is used, the connection to the queue will not be established and the error messages you get will not immediately reflect the cause of the error. The formats required (Remote JNDI names for AQ JMS Connection Factories) are described in the section Configure AQ Destinations  of the Oracle® Fusion Middleware Configuring and Managing JMS for Oracle WebLogic Server document mentioned earlier.

In this example, the remote JNDI name used is   XAQueueConnectionFactory  because it matches the AQ and data source created earlier, i.e. thin with AQ.

Navigate to JMS Modules > AqJmsModule > AqJmsForeignServer > Connection Factories then New.
Name:
AqJmsForeignServerConnectionFactory

Local JNDI Name: AqJmsForeignServerConnectionFactory

Note: this local JNDI name is the JNDI name which your client application, e.g. a later BPEL process, will use to access this connection factory.

Remote JNDI Name: XAQueueConnectionFactory
Press OK to save the configuration.

Configure an AQ JMS Foreign Server Destination

A foreign server destination maps the JNDI name on the foreign JNDI provider to the respective local JNDI name, allowing the foreign JNDI name to be accessed via the local server. As with the foreign server connection factory, the local JNDI name is arbitrary (but must be unique), but the remote JNDI name must conform to a specific format defined in the section Configure AQ Destinations  of the Oracle® Fusion Middleware Configuring and Managing JMS for Oracle WebLogic Server document mentioned earlier.

In our example, the remote JNDI name is Queues/USERQUEUE , because it references a queue (as opposed to a topic) with the name USERQUEUE. We will name the local JNDI name queue/USERQUEUE, which is a little confusing (note the missing “s” in “queue), but conforms better to the JNDI nomenclature in our SOA server and also allows us to differentiate between the local and remote names for demonstration purposes.

Navigate to JMS Modules > AqJmsModule > AqJmsForeignServer > Destinations and select New.
Name:
AqJmsForeignDestination

Local JNDI Name: queue/USERQUEUE

Remote JNDI Name:Queues/USERQUEUE

After saving the foreign destination configuration, this completes the JMS part of the configuration. We still need to configure the JMS adapter in order to be able to access the queue from a BPEL processt.

4. Create a JMS Adapter Connection Pool in Weblogic Server

Create the Connection Pool

Access to the AQ JMS queue from a BPEL or other SOA process in our example is done via a JMS adapter. To enable this, the JmsAdapter in WebLogic server needs to be configured to have a connection pool which points to the local connection factory JNDI name which was created earlier.

Navigate to Deployments > Next and select (click on) the JmsAdapter.


Select Configuration > Outbound Connection Pools and
New.

Check the radio button for oracle.tip.adapter.jms.IJmsConnectionFactory and press Next.

JNDI Name: eis/aqjms/UserQueue

Press Finish

Expand oracle.tip.adapter.jms.IJmsConnectionFactory and click on eis/aqjms/UserQueue to configure it.


The ConnectionFactoryLocation must point to the foreign server’s local connection factory name created earlier. In our example, this is
AqJmsForeignServerConnectionFactory . As a reminder, this connection factory is located under JMS Modules > AqJmsModule > AqJmsForeignServer > Connection Factories and the value needed here is under Local JNDI Name.

Enter AqJmsForeignServerConnectionFactory  into the Property Value field for ConnectionFactoryLocation. You must then press Return/Enter then Save for the value to be accepted.


If your WebLogic server is running in Development mode, you should see the message that the changes have been activated and the deployment plan successfully updated. If not, then you will manually need to activate the changes in the WebLogic server console.

Although the changes have been activated, the JmsAdapter needs to be redeployed in order for the changes to become effective. This should be confirmed by the message
Remember to update your deployment to reflect the new plan when you are finished with your changes.

Redeploy the JmsAdapter

Navigate back to the Deployments screen, either by selecting it in the left-hand navigation tree or by selecting the “Summary of Deployments” link in the breadcrumbs list at the top of the screen. Then select the checkbox next to JmsAdapter and press the Update button.

On the Update Application Assistant page, select “Redeploy this application using the following deployment files” and press Finish.

After a few seconds you should get the message that the selected deployments were updated.

The JMS adapter configuration is complete and it can now be used to access the AQ JMS queue. You can verify that the JNDI name was created correctly, by navigating to Environment > Servers > soa_server1 and View JNDI Tree. Then scroll down in the JNDI Tree Structure to eis and select aqjms.


This concludes the sample.

In the following post, I will show you how to create a BPEL process which sends a message to this advanced queue via JMS.

Best regards
John-Brown Evans
Oracle Technology Proactive Support Delivery

About

This is the official blog of the SOA Proactive Support Team. Here we will provide information on our activities, publications, product related information and more. Additionally we look forward to your feedback to improve what we do.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today