Working with AQ Adapter in SOA



Introduction to the Oracle AQ Adapter:

Oracle Streams Advanced Queuing (AQ) provides a flexible mechanism for bidirectional, asynchronous communication between participating applications. Advanced queues are an Oracle database feature, and are therefore scalable and reliable. Other features of Oracle database, such as backup and recovery (including any-point-in-time recovery), logging, transactional services, and system management, are also inherited by advanced queues. Multiple queues can also service a single application, partitioning messages in a variety of ways and providing another level of scalability through load balancing.

Oracle AQ Adapter Features:


  • The Oracle AQ Adapter is both a producer and a consumer of AQ messages. The enqueue operation is exposed as a JCA outbound interaction. The dequeue operation is exposed as a JCA inbound interaction.
  • The Oracle AQ Adapter supports ADT (Oracle object type), XMLType, and RAW queues as payloads. It also supports extracting a payload from one ADT member column.
  • The Oracle AQ Adapter supports normalized properties for enqueue and dequeue operations.

·         The Oracle AQ Adapter supports the following features of Oracle Streams AQ:

o    Correlation Identifier
o    Multiconsumer Queue
o    Message Priority
o    Time Specification and Scheduling and many more.

(For more about AQ Adapter refer Oracle® Fusion Middleware User's Guide for Technology Adapters 11g Release 1 (11.1.1.6.0)).



SQL Script to create the AQ table & Message Type:

SQL>CONNECT sys/change_on_install as sysdba

SQL>DROP USER aq_user CASCADE;

SQL>CREATE USER aq_user IDENTIFIED BY aq_user
  DEFAULT TABLESPACE users
  TEMPORARY TABLESPACE temp;

SQL>ALTER USER aq_user QUOTA UNLIMITED ON users;

SQL>GRANT aq_administrator_role TO aq_user;
SQL>GRANT connect               TO aq_user;
SQL>GRANT create type           TO aq_user;
SQL>GRANT create sequence       TO aq_user;

SQL>EXECUTE dbms_aqadm.grant_type_access ('aq_user');

-- Login as AQ_User

SQL>CONNECT aq_user/aq_user

SQL>CREATE TYPE message_type AS OBJECT (message_id NUMBER (15),subject VARCHAR2(100),text VARCHAR2(100),dollarvalue NUMBER(4,2));

SQL>BEGIN
   -- ----------------------------------------------------

    DBMS_AQADM.CREATE_QUEUE_TABLE (
        queue_table        => 'aq_user.msg_qt'
      , queue_payload_type => 'aq_user.message_type'
    );

    -- ----------------------------------------------------

    DBMS_AQADM.CREATE_QUEUE (
        queue_name          => 'msg_queue'
      , queue_table         => 'aq_user.msg_qt'
      , queue_type          => DBMS_AQADM.NORMAL_QUEUE
      , max_retries         => 0
      , retry_delay         => 0
      , retention_time      => 1209600
      , dependency_tracking => FALSE
      , comment             => 'Test Object Type Queue'
      , auto_commit         => FALSE
    );
    -- ----------------------------------------------------

    DBMS_AQADM.START_QUEUE ('msg_queue');

    -- ----------------------------------------------------
END;

Script to Stop and Drop the Queue:
 
SQL>CONNECT aq_user/aq_user
 
EXECUTE dbms_aqadm.stop_queue (queue_name => 'aq_user.msg_queue');
EXECUTE dbms_aqadm.drop_queue (queue_name => 'aq_user.msg_queue');
EXECUTE
dbms_aqadm.drop_queue_table (queue_table => 'aq_user.msg_qt');
 
SQL>DROP TYPE aq_user.message_type;
 
 

Weblogic configuration for AQ Adapter:
Login to Weblogic server console. Then create a Data source. For this go to the Data Sources section. Create JDBC Data source localhost-aq whose JNDI name is jndi/localhost-aq
 
 





Now under Deployments select AQAdapter, Configurations Tab and Outbound Connection, Create a new Outbound Connection eis/aq/localhost-aq who’s XADataSourceName is jndi/localhost-aq




Below are Data source details to aq_user user in database



This will be deployed on Admin Server, as my SOA installation is running on Admin server.



Save
 

Update the AQAdapter Deployment, Update the plan, no restart needed.

Soa 11g bpel process using enqueue:

Let’s create a simple Asynchronous BPEL process my-aq-app, Under External Reference Insert AQ Adapter.




Edit the BPEL Process use Invoke activity to connect to AQ Adapter 

 

This is how the BPEL would look like 

 

Add assign before invoke to wire input variables to AQ input variables.

  

These are Details of AQ Adapter



Create a DB Connection by name localhost-aq


Note: JNDI name should match to the one that we configured in the Weblogic Console






Comments

  1. Hi subhash,
    Thx for good article,It is very useful me.I follow the same but I got ora-01031 insufficient privileges while creating the queue qnd queue table.Any suggesstion would be appriciate.

    Regrads
    Mani

    ReplyDelete
    Replies
    1. Hey Mani,

      Can you mail me that error exactly you are getting?
      My mail id: subbu.3823@gmail.com
      It would be great if you provide more information regarding this error.


      Regards,
      Subhash Venkata

      Delete
    2. Hi subhash thx for quick reply,

      I created the user and grant the privileges but I am able to create the message_type also but while execute the following query I got "ora-01031 insufficient privileges"
      BEGIN
      -- ----------------------------------------------------

      DBMS_AQADM.CREATE_QUEUE_TABLE (
      queue_table => 'aq_user.msg_qt'
      , queue_payload_type => 'aq_user.message_type'
      );

      -- ----------------------------------------------------

      DBMS_AQADM.CREATE_QUEUE (
      queue_name => 'msg_queue'
      , queue_table => 'aq_user.msg_qt'
      , queue_type => DBMS_AQADM.NORMAL_QUEUE
      , max_retries => 0
      , retry_delay => 0
      , retention_time => 1209600
      , dependency_tracking => FALSE
      , comment => 'Test Object Type Queue'
      , auto_commit => FALSE
      );
      -- ----------------------------------------------------

      DBMS_AQADM.START_QUEUE ('msg_queue');

      -- ----------------------------------------------------
      END;

      Delete
  2. Hi Mani,

    I tried the above script in my machine now, it was executed successfully without any errors. It is strange to me why it is giving error to you.. can you please ping me on gtalk @subbu.3823@gmail.com, I can help you instantly...


    Regards
    Subhash.

    ReplyDelete
  3. Hi Subhash,
    For me Enque is happening but how to use is for Deque..?

    ReplyDelete
  4. Hi Subhash,
    Thanks for the wonderful article.
    I have doubt:
    1. Does AQ has the retry mechanism in case of failure like JMS.
    2. Also for enqueue and dequeue, do we need to write parser.

    Please suggest.
    Thanks in advance.

    ReplyDelete
  5. Hi,

    Nice article with very helpful tips on using AQ Adapter in SOA.
    wso2 provides Open source solution for exchange communications asynchronously or publish messages for timely access by many subscribers vial wso2 Message Broker (http://wso2.com/products/message-broker/).
    More specifically a sample on sending and receiving messages using queues with wso2 Message Broker is available at (https://docs.wso2.com/display/MB210/Sending+and+Receiving+Messages+Using+Queues).

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  6. Here I came to know that The Oracle AQ Adapter supports normalized properties for enqueue and dequeue operations.your explanation on working with aq adapter with nice screenshots is useful to me in my oracle SOA online training and given confident to do more.thank you.

    ReplyDelete
  7. Such an ideal piece of blog. I appreciate your blog
    Oracle SOA Online Training

    ReplyDelete
  8. Thanks a lot for sharing a valuable blog on Oracle SOA Training. I was browsing through the internet looking for Oracle SOA Training and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can find more information about Oracle SOA by attending Oracle SOA Training. You can learn about interview questions by visiting fusion Interview Questions

    ReplyDelete
  9. Thanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle SOA Interview Questions and Answers
    . Actually, I was looking for the same information on internet for
    Oracle SOA Training and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more about Oracle SOA Tutorial also.

    ReplyDelete
  10. do we have any purge script to delete AQ messages?

    ReplyDelete
  11. I wish to show thanks to you just for bailing me out of this particular trouble. As a result of checking through the net and meeting techniques that were not productive, Same as your blog I found another one Oracle OSB 12c.Actually I was looking for the same information on internet for Oracle OSB 12c and came across your blog. I am impressed by the information that you have on this blog. Thanks once more for all the details.

    ReplyDelete
  12. Thanks for sharing this blog. The content is beneficial and useful. Very informative post. Visit here to learn more about Data Warehousing companies and Data analytics Companies. I am impressed by the information that you have on this blog. Thanks once more for all the details.Visit here for Top Big Data Companies.

    ReplyDelete

Post a Comment

Popular posts from this blog

Difference between Route, Service Callout, Publish

OSB actions in proxy service

XQuery functions that supported by OSB