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

Posted by John-Brown.Evans on Oracle Blogs See other posts from Oracle Blogs or by John-Brown.Evans
Published on Wed, 19 Dec 2012 16:29:29 +0000 Indexed on 2012/12/19 17:08 UTC
Read the original article Hit count: 740

Filed under:
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 Sample Program to Send a Message to a JMS Queue
  3. JMS Step 3 - Using the 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




Database User


Advanced Queue (AQ) Table


Advanced Queue

WebLogic Server Objects

Object Name




Data Source



JMS System Module


JMS Foreign Server


JMS Foreign Server Connection Factory



AQ JMS Foreign Destination



Connection Pool


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:


<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd=""
 <xsd:element name="exampleElement" type="xsd:string">

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

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

© Oracle Blogs or respective owner

Related posts about /Oracle