0% found this document useful (0 votes)
114 views45 pages

Working With Oracle Queues: Choosing Between AQ and JMS

JMS_vs_AQ

Uploaded by

buddhi1231443
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views45 pages

Working With Oracle Queues: Choosing Between AQ and JMS

JMS_vs_AQ

Uploaded by

buddhi1231443
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Working with Oracle Queues

Choosing between AQ and JMS

Ahmed Aboulnaga
Technical Director
Raastech, Inc.
Agenda

1. Introduction
2. Overview of Messaging
3. Asynchronous Messaging
4. Oracle Queues
5. Creating Queues
6. Accessing Queues
7. Oracle WebLogic JMS Bridge
8. Performance & Comparison
9. Summary

Slide 2 of 45 © Raastech, Inc. 2011 | All rights reserved.


INTRODUCTION

Slide 3 of 45 © Raastech, Inc. 2011 | All rights reserved.


Applicable Versions

 Oracle Database 10g (10.2.0.x)


 Oracle Database 11g (11.1.x)

 Oracle Application Server 10g (10.1.x)


 Oracle WebLogic Server 11g (10.3.3+)

 Oracle SOA Suite 10g (10.1.3.x)


 Oracle SOA Suite 11g (11.1.1.3+)

Slide 4 of 45 © Raastech, Inc. 2011 | All rights reserved.


Applicable Versions

 Oracle Database 10g (10.2.0.x)


 Oracle Database 11g (11.1.x)

 Oracle Application Server 10g (10.1.x)


 Oracle WebLogic Server 11g (10.3.3+)

 Oracle SOA Suite 10g (10.1.3.x)


 Oracle SOA Suite 11g (11.1.1.3+)

Slide 5 of 45 © Raastech, Inc. 2011 | All rights reserved.


OVERVIEW OF MESSAGING

Slide 6 of 45 © Raastech, Inc. 2011 | All rights reserved.


Introduction to Messaging
Synchronous Transactions

 Request-response scenarios are synchronous by nature

 A request is made by the client application, and a response


is received (on the same thread) by the target application

Slide 7 of 45 © Raastech, Inc. 2011 | All rights reserved.


Introduction to Messaging
Synchronous Transactions – Under Load

 When numerous, simultaneous requests are made, the


target system may be overloaded
 Each layer has a limit to how much it can handle:
– Oracle HTTP Server (number of HTTP connections)
– Application Server (number of threads)
– Database Server (number of processes)

Slide 8 of 45 © Raastech, Inc. 2011 | All rights reserved.


Introduction to Messaging
Asynchronous Transactions May Be the Solution

 The client application ‘enqueues’ or ‘produces’ a message


to a queue
 The target application can ‘dequeue’ or ‘consume’ the
message at its own pace

Oracle Queue

Slide 9 of 45 © Raastech, Inc. 2011 | All rights reserved.


ASYNCHRONOUS MESSAGING

Slide 10 of 45 © Raastech, Inc. 2011 | All rights reserved.


Asynchronous Messaging
Overview

 Queues allow ‘indirect’ communication

 Asynchronous messaging is a form of loosely coupled


distributed communication

 Messages are usually structured XML

 Senders do not need to have precise knowledge of their


receivers

Slide 11 of 45 © Raastech, Inc. 2011 | All rights reserved.


Asynchronous Messaging
Payload Format

 Messages are almost always in XML format

<ns4:elements xmlns:ns4="http://ns.raastech.com/Order">
<ns4:element>
<ns4:orderNumber>269041</ns4:orderNumber>
<ns4:quantity>12</ns4:quantity>
<ns4:product>Milky Way</ns4:product>
<ns4:price>0.99</ns4:price>
</ns4:element>
</ns4:elements>

Slide 12 of 45 © Raastech, Inc. 2011 | All rights reserved.


Asynchronous Messaging
When should you consider queues?

 When downtime scheduled by target applications do not


synchronize with client applications
 When an immediate response is not required
 When you want to integrate heterogeneous systems
without the client having precise knowledge of their
receiver
 When you want to reduce bottlenecks
 When you want to implement priority
 When you want to implement a publish-subscribe model,
where a single message can be propagated to multiple
consumers
Slide 13 of 45 © Raastech, Inc. 2011 | All rights reserved.
Asynchronous Messaging
Queue Approaches

Can be dequeued
based on priority or
enqueue time

Like JMS topics, can Explicit


be (and implicit) recipients
multi-
consumer; messages can be
can remain specified
in when
messages
the queue for a specified are enqueued
time period

Slide 14 of 45 © Raastech, Inc. 2011 | All rights reserved.


Asynchronous Messaging
Types of Queues

 Oracle AQ (Advanced Queue)

 OJMS (Oracle JMS)

 WebLogic JMS

Slide 15 of 45 © Raastech, Inc. 2011 | All rights reserved.


ORACLE QUEUES

Slide 16 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
Oracle AQ

 Database-integrated message queuing functionality


 Built on top of Oracle Streams
 Leverages the functions of Oracle Database
(high availability, scalability, indexing, recovery, security, etc.)
 Can be monitored by tools such as OEM
 Queue tables can be imported and exported
 Messages can be queried using standard SQL
(to access message properties, history, and payload)
 Does not support DML operations

Slide 17 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
Oracle AQ

COUNT QUEUE CONSUMER_NAME ACTION_NAME FROM_PARTY TO_PARTY


----- ------------- ------------- ---------------- ---------- ----------
3 AQ$_QTAB_E B2BUSER PROCESS_OTM CNTRL Essentials
1 HL7_OUT_QUEUE B2BUSER PROCESS_OTM CNTRL Essentials
644 IP_IN_QUEUE B2BERRORUSER Exception CNTRL HI
1800 IP_IN_QUEUE B2BERRORUSER Exception CNTRL Essentials
1 IP_IN_QUEUE OTMUSER PROCESS_OTM_O01 CCS CNTRL

Slide 18 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
Oracle JMS

 JMS implementation and interface

 Underlying model is AQ

 All the benefits of AQ

 All the accessibility of JMS

Slide 19 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
WebLogic JMS

 JMS = Java Message Service


 JMS is a standard API for accessing enterprise messaging
systems
 Enables Java applications that share a messaging system
to exchange messages
 Simplifies application development by providing a standard
interface for creating, sending, and receiving messages
 Java and SOA applications can move from one JMS
provider to another without any code modification

Slide 20 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
WebLogic JMS

 WebLogic JMS queues can be based off of a:


– JDBC Persistent Store
– File Persistent Store

 Database-persisted WebLogic JMS queues ≠ OJMS

Slide 21 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
WebLogic JMS

Slide 22 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
WebLogic JMS Architecture

Slide 23 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
WebLogic JMS Architecture

Persistent Store

JMS Server

JMS Module
 Subdeployment Queue Topic

Slide 24 of 45 © Raastech, Inc. 2011 | All rights reserved.


CREATING QUEUES

Slide 25 of 45 © Raastech, Inc. 2011 | All rights reserved.


Creating Queues
Creating an Oracle AQ
EXECUTE dbms_aqadm.create_queue_table (
queue_table => 'MyAQQueueTable',
queue_payload_type => 'SYS.XMLType',
multiple_consumers => true,
max_retries => 5,
queue_type => 0, -- normal queue
sort_list => 'PRIORITY, ENQ_TIME',
compatible => '10.0.0');

EXECUTE dbms_aqadm.create_queue (
queue_name => 'MyAQQueue',
queue_table => 'MyAQQueueTable');

EXECUTE dbms_aqadm.start_queue (
queue_name => 'MyAQQueue',
enqueue => TRUE,
dequeue => TRUE);

Slide 26 of 45 © Raastech, Inc. 2011 | All rights reserved.


Creating Queues
Creating an Oracle JMS Queue (OJMS)

EXECUTE sys.dbms_aqadm.create_queue_table (
queue_table => 'MyJMSQueueTable',
queue_payload_type => 'SYS.AQ$_JMS_MESSAGE',
sort_list => 'PRIORITY, ENQ_TIME',
compatible => '10.0.0',
storage_clause => 'tablespace pctfree 10 initrans 1
maxtrans 255 storage ( initial 64K
minextents 1 maxextents unlimited )');

EXECUTE sys.dbms_aqadm.create_queue (
queue_name => 'MyJMSQueue',
queue_table => 'MyJMSQueueTable',
queue_type => sys.dbms_aqadm.normal_queue);

EXECUTE dbms_aqadm.start_queue (
queue_name => 'MyJMSQueue');

Slide 27 of 45 © Raastech, Inc. 2011 | All rights reserved.


Creating Queues
Creating a WebLogic JMS Queue
Create Persistent Store
 Log in to the WebLogic Server Administration Console
 Navigate to “soa_domain  Services  Persistent Stores”
 Create a new Persistent Database Store or Persistent File Store (e.g., MyJMSFileStore)
Create JMS Server
 Navigate to “soa_domain  Services  Messaging  JMS Servers”
 Create a new JMS Server (e.g., MyJMSServer)
Create JMS Module
 Navigate to “soa_domain  Services  Messaging  JMS Modules”
 Create a new JMS Module (e.g., MyJMSModule)
Create Subdeployment
 Navigate to “soa_domain  Services  Messaging  JMS Modules”
 Click on “MyJMSModule” and create a new “Subdeployments” (e.g., MySubdeployment)
Create Queue
 Navigate to “soa_domain  Services  Messaging  JMS Modules”
 Click on “MyJMSModule” and create a new Queue using the Subdeployment (e.g., MyJMSQueue)

Slide 28 of 45 © Raastech, Inc. 2011 | All rights reserved.


ACCESSING QUEUES

Slide 29 of 45 © Raastech, Inc. 2011 | All rights reserved.


Accessing Queues
Enqueing Messages via PL/SQL
DECLARE
l_message clob := '';
v_enqueue_options dbms_aq.enqueue_options_t;
v_msg_props dbms_aq.message_properties_t;
v_msg_id RAW(16);
v_message SYS.AQ$_JMS_MESSAGE :=
SYS.AQ$_JMS_MESSAGE.construct(DBMS_AQ.JMS_TEXT_MESSAGE);
BEGIN
l_message := '<ns4:elements xmlns:ns4="http://ns.raastech.com/Person">
<ns4:element>
<ns4:firstName>Ahmed</ns4:firstName>
<ns4:lastName>Naga</ns4:lastName>
</ns4:element>
</ns4:elements>';
v_message.set_text(xmltype(l_message).getstringval());
dbms_aq.enqueue(
queue_name => 'MyJMSQueue',
enqueue_options => v_enqueue_options,
message_properties => v_msg_props,
payload => v_message,
msgid => v_msg_id);
COMMIT;
END;
/

Slide 30 of 45 © Raastech, Inc. 2011 | All rights reserved.


Accessing Queues
Producing Messages via Oracle SOA Suite

 Oracle SOA Suite provides


adapters to access
resources such as AQ,
JMS, and OJMS
 Messages can be
enqueued and dequeued
via the ‘AQ Adapter’
 Messages can be
produced and consumed
via the ‘JMS Adapter’

Slide 31 of 45 © Raastech, Inc. 2011 | All rights reserved.


Accessing Queues
Enqueuing Messages via Java
// Create data object
pers = new PERSON();
pers.setName("Ahmed");

// Open a connection and get queue


db_conn = ((AQOracleSession)aq_sess).getDBConnection();
queue = aq_sess.getQueue("aquser", "MyAQQueue");

// Create a message and set payload


message = queue.createMessage();
payload = message.getObjectPayload();
payload.setPayloadData(pers);

// Enqueue a message into MyAQQueue


eq_option = new AQEnqueueOption();
queue.enqueue(eq_option, message);

// Commit
db_conn.commit();

Slide 32 of 45 © Raastech, Inc. 2011 | All rights reserved.


Accessing Queues
Producing Messages via Java
// Create InitialContext
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
properties.put(Context.SECURITY_PRINCIPAL, "weblogic");
properties.put(Context.SECURITY_CREDENTIALS, "welcome1");
// Create QueueConnectionFactory
qcf = (QueueConnectionFactory)ctx.lookup("jms/MyConnectionFactory");
// Create QueueConnection
qc = qcf.createQueueConnection();
// Create QueueSession
qsess = qc.createQueueSession(false, 0);
// Lookup Queue
q = (Queue)ctx.lookup("jms/MyQueue");
// Create QueueSender
qsndr = qsess.createSender(q);
// Create TextMessage
message = qsess.createTextMessage();
// Set message text in TextMessage
message.setText(messageText);
// Send message
qsndr.send("<person><firstName>Ahmed</firstName></person>");

Slide 33 of 45 © Raastech, Inc. 2011 | All rights reserved.


ORACLE WEBLOGIC JMS BRIDGE

Slide 34 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle WebLogic JMS Bridge
Bridging Oracle AQ and WebLogic JMS Queues

 Viewed from within code as a regular JMS Queue


 Underlying storage is Oracle AQ
 The WebLogic Messaging Bridge is a forwarding mechanism
 The WebLogic Messaging Bridge can be used with other
messaging products
– To JMS queues in other WebLogic domains
– To 3rd party JMS providers (e.g., MQSeries)
 Did not have time to experiment and document

Slide 35 of 45 © Raastech, Inc. 2011 | All rights reserved.


PERFORMANCE & COMPARISON

Slide 36 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
Comparison

Oracle AQ Oracle JMS WebLogic JMS


Not Proprietary   
Database   
File System   
Memory   
Persisted   
Centralized access   
across midtiers/apps (only if NFS shared)

Best Performance   *
Least Problems  ? 

Slide 37 of 45 © Raastech, Inc. 2011 | All rights reserved.


10 threads
Oracle Queues 50 ms test delay
Performance Summary 0.5 randomness
324 byte payload size
Messages Action DB Table AQ JMS JMS
(file-based) (db-based)

1000 Enqueue 0:20 0:22 0:54 1:21

Dequeue 4:20 2:42 2:09 2:35

Last Proc Time 1:15 1:14 1:15


? enqueue
Errors
? dequeue

5000 Enqueue 5:45 3:40 4:25

Dequeue Issues 9:52 11:06 10:12


29 enqueue
Errors Issues
3 dequeue

Slide 38 of 45 © Raastech, Inc. 2011 | All rights reserved.


5 threads
Oracle Queues 50 ms test delay
Performance Summary 0 randomness
324 byte payload size

Time Action AQ JMS JMS


(file-based) (db-based)

60 secs Enqueue
(Avg Proc Time)
0.745 0.009 0.007
Dequeue
(Avg Proc Time)
0.059 0.030 0.029

Total Messages 1865 1354 1621

Errors 2

Slide 39 of 45 © Raastech, Inc. 2011 | All rights reserved.


Oracle Queues
5 threads
Performance Summary
50 ms test delay
0 randomness
324 byte payload size

Time Action AQ JMS JMS


(file-based) (db-based)

300 secs Messages 7842 7769 7574


Time to
Complete
6:50 9:34 8:16

Last Proc Time 1:43 4:40 3:09

Errors 5 (pool)

Slide 40 of 45 © Raastech, Inc. 2011 | All rights reserved.


SUMMARY

Slide 41 of 45 © Raastech, Inc. 2011 | All rights reserved.


Summary
Choosing Queue Technology

 Oracle AQ
– Use if you are running Oracle E-Business Suite
– Use for database-driven applications
– Avoid the Oracle SOA Suite ‘AQ Adapter’, as many projects
have complained of enqueue/dequeue issues

 WebLogic JMS
– Recommend using for Java and SOA based applications
– Use if you are considering switching queue (JMS) providers
– Oracle states that file-based persistent stores are considerably
faster than JDBC-based persistent stores, but tests have
shown otherwise

Slide 42 of 45 © Raastech, Inc. 2011 | All rights reserved.


Summary
Final Thoughts

 There are many other areas related to Oracle Queue


technologies, such as:
– AQ propagation
– WebLogic JMS queue failover
– Store-and-forward
– High availability
– Notifications
– Exception queues
– Guaranteed delivery

Slide 43 of 45 © Raastech, Inc. 2011 | All rights reserved.


Summary
References
 Introduction to Advanced Queues (AQ)
http://blog.raastech.com/2008/05/introduction-to-advanced-queues-aq.html
 Creating a JMS queue for SOA consumption
http://blog.raastech.com/2009/03/creating-jms-queue-for-soa-consumption.html
 Creating an AQ queue for SOA consumption
http://blog.raastech.com/2011/03/create-aq-queue-for-soa-consumption.html
 Introduction to Oracle Streams AQ
http://download.oracle.com/docs/cd/B28359_01/server.111/b28420/aq_intro.htm
 Introduction to Oracle JMS
http://download.oracle.com/docs/cd/B28359_01/server.111/b28420/jm_create.htm
 Configuring and Managing WebLogic JMS
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/jms_admin/index.html
 Oracle Fusion Middleware Developer’s Guide for Oracle SOA Suite 11g Release 1 (11.1.1)
http://download.oracle.com/docs/cd/E12839_01/integration.1111/e10224/title.htm
 Oracle Streams Advanced Queuing User's Guide 11g Release 1 (11.1)
http://www.oracle.com/pls/db111/portal.portal_db?selected=15
 An updated simple WebLogic JMS client
http://redstack.wordpress.com/2010/02/17/an-updated-simple-weblogic-jms-client

Slide 44 of 45 © Raastech, Inc. 2011 | All rights reserved.


Contact Information

Ahmed Aboulnaga
Technical Director
571-249-1155
ahmed.aboulnaga@raastech.com

Slide 45 of 45 © Raastech, Inc. 2011 | All rights reserved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy