Advanced Queuing

Date: 20/May/2002

Internet Data Access Protocol

Objective

After completing this snippet you should be able to understand the following:

  •   What is Internet Data Access Protocol?
  •   Steps followed to perform Advanced Queuing operations using Internet Data Access Protocol.

Notation

  • IDAP - Internet Data Access Protocol
  • AQ - Advanced Queuing
  • SOAP - Simple Object Access protocol
  • <oracle_home> - Folder where Oracle Database is installed

Introduction

IDAP is the SOAP specification for performing AQ operations.It enables advanced queuing operations to be performed over HTTP and HTTPS using XML.

Pre-requisites

  • Oracle9i or higher version
  • Java and Servlets

Description

In IDAP the communication between the HTTP client and the database takes place through a servlet called AQServlet. The basic steps required for communication through IDAP are:

1) Create the AQServlet

First the AQServlet must be created and compiled. The steps for configuration of AQServlet are mentioned here.

2) Authenticate the user

The AQServlet allows only authenticated users to access the servlet. So the Web server must be configured to Authenticate the users.

3) Authorize the user

The users must be authorized to access the database from the AQServlet. This is done by registering the user and mapping the user to the database. The commands are:

EXECUTE dbms_aqadm.create_aq_agent(agent_name=>'bob', enable_http =>true);
EXECUTE dbms_aqadm.enable_db_access('bob', 'producer');

where bob is the username used to authenticate the user.

4) Send IDAP request to AQServlet

Requests are sent to AQServlet using the POST method. The body of the IDAP message depends on the type of the request made. For an enqueue request the format of IDAP message is as given below:

If the message is enqueued to a topic of multiconsumer queue, instead of the tag AQXmlSend you can use the AQXmlPublish tag. Payload contains the actual data that is to be propagated. The structure of message_payload depends on the payload that is specified in the queue table. In this case the payload is:

CREATE OR REPLACE TYPE customerorders AS OBJECT
 ( customer_id     VARCHAR2(40),
   order_date      DATE,

   order_total     NUMBER(8,2),
 )
/

If the payload is an array of nested table created using the script mentioned below, the corresponding payload will be in the following format:

            Script

CREATE OR REPLACE TYPE purchased_products
  AS OBJECT
  (
    product_id        VARCHAR2(10),
    manufacturer_id   VARCHAR2(5),
    quantity_ordered  NUMBER(6)
)
/


CREATE TYPE products_table
    AS TABLE OF purchased_products
/

CREATE OR REPLACE TYPE products_arr IS
  VARRAY(1) OF products_table
/

CREATE OR REPLACE TYPE customerorders
AS OBJECT
 ( customer_id     VARCHAR2(40),
   order_date      DATE,
   order_total     NUMBER(8,2),
   orders_array    products_arr

 )
/
 
                   Message Payload

<message_payload>
<CUSTOMERORDERS>
<CUSTOMER_ID>aq</CUSTOMER_ID>
<ORDER_DATE>05/08/2002 16:17:16</ORDER_DATE>
<ORDER_TOTAL>999</ORDER_TOTAL>
<ORDERS_ARRAY>
<ORDERS_ARRAY_ITEM>
<ORDERS_ARRAY_ITEM_ITEM>
<PRODUCT_ID>P113</PRODUCT_ID>
<MANUFACTURER_ID>C1000</MANUFACTURER_ID> <QUANTITY_ORDERED>1</QUANTITY_ORDERED> </ORDERS_ARRAY_ITEM_ITEM>
</ORDERS_ARRAY_ITEM>
</ORDERS_ARRAY>
</CUSTOMERORDERS> </message_payload>
 

The response to the enqueue operation depends on the success or the failure of the enqueue operation. The response will be in the following format:

If the messages are enqueued to a multiconsumer queue then the response tag contains AQXmlPublish response instead of AQXmlSendResponse and publish_result instead of send_result.

In a similar fashion messages can be dequeued using SOAP. In such case, a dequeue request of the format given below must be sent to the AQServlet.

If the dequeue_mode is Remove, after dequeuing the messages are removed from the queue. The dequeue_ mode can also be Browse or Locked. Along with these tags another tag that is significant is <transformation></transformation>. This tag specifies the transformation function that is to be used before dequeuing.

If the dequeue operation is successful, the response will be of the form

Resources



E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy