Presentation is loading. Please wait.

Presentation is loading. Please wait.

Wilfried Mausz Oracle Advanced Queueing. Wilfried Mausz Agenda Queues Models Requirements Creating and using a queue Live demos –Point-to-point queue.

Similar presentations


Presentation on theme: "Wilfried Mausz Oracle Advanced Queueing. Wilfried Mausz Agenda Queues Models Requirements Creating and using a queue Live demos –Point-to-point queue."— Presentation transcript:

1 Wilfried Mausz Oracle Advanced Queueing

2 Wilfried Mausz Agenda Queues Models Requirements Creating and using a queue Live demos –Point-to-point queue in PL/SQL –Publish-Subscribe –Accessing a queue from.net

3 Wilfried Mausz Queues Definition queue –Priority queue Definition enqueue and dequeue Feature list Scenarios for the use of queues Examples

4 Wilfried Mausz Queue A Queue can be visualized as a queue of people. People join the tail of the queue and wait until they reach the head. Queue

5 Wilfried Mausz Queue Definition: In providing services to people, and in computer science, transportation, and operations research a queue is a First- In-First-Out FIFO process — the first element in the queue will be the first one out. This is equivalent to the requirement that whenever an element is added, all elements that were added before have to be removed before the new element can be removed.

6 Wilfried Mausz Priority queue A priority queue is an abstract data type supporting the following two operations: –add an element to the queue with an associated priority –remove the element from the queue that has the highest priority, and return it

7 Wilfried Mausz Enqueue and dequeue Enqueue … writing message to queue Dequeue … reading (and removing) message from queue queue payload queue payload

8 Wilfried Mausz Features Asynchronous communication between database applications Integration of messaging and database Internet support (HTTP, , …) Message queueing is transactional Transformation of messages Priority queues Scheduled queues Interfaces to other systems (IBM MQSeries, Tibco, …)

9 Wilfried Mausz Features Overview Advanced Queues

10 Wilfried Mausz Scenarios Asynchronous import and export of data Asynchronous working on data Communication between different applications Scheduled operations on data E-business applications –Communication with trading partners Enterprise Application Integration (EAI) Example: Milestone Export Application

11 Wilfried Mausz Models Point-to-point queue Publish-Subscribe model

12 Wilfried Mausz Point-to-Point model Two systems using one ore more queues to communicate with each other One message just can be dequeued once Application Queues enqueuedequeue

13 Wilfried Mausz Publish-Subscribe model No connection between the applications More than one receiving applications (agents) Publisher applications put messages to the queue (topics) Messages are addressed for specific applications or received by all –Broadcast (like TV, radio) –Multicast (like newspaper) Application Queues publish / subscribe / receive subscribe / receive

14 Wilfried Mausz Requirements Oracle database (>8) Packages Permissions

15 Wilfried Mausz Packages DBMS_AQADM –Creating or dropping queue tables that contain one or more queues –Creating, dropping, and altering queues, which are stored in a queue table –Starting and stopping queues in accepting message creation or consumption DBMS_AQ –Creating a message to the specified queue –Consuming a message from the specified queue

16 Wilfried Mausz Permissions AQ administrator –Create queues –Owner of queues Queue users –Access queues

17 Wilfried Mausz Permissions CREATE ROLE my_aq_adm_role; GRANT CONNECT, RESOURCE, aq_administrator_role TO my_aq_adm_role; CREATE ROLE my_aq_user_role; GRANT CREATE SESSION, aq_user_role TO my_aq_user_role;

18 Wilfried Mausz Permissions EXEC DBMS_AQADM.GRANT_SYSTEM_PRIVILEGE( privilege => 'ENQUEUE_ANY', grantee => 'my_aq_user_role', admin_option => FALSE); EXEC DBMS_AQADM.GRANT_SYSTEM_PRIVILEGE( privilege => 'DEQUEUE_ANY', grantee => 'my_aq_user_role', admin_option => FALSE);

19 Wilfried Mausz Permission CREATE USER aqadm IDENTIFIED BY aqadm DEFAULT TABLESPACE tab TEMPORARY TABLESPACE temp; GRANT my_aq_adm_role TO aqadm; CREATE USER aquser IDENTIFIED BY aquser DEFAULT TABLESPACE tab TEMPORARY TABLESPACE temp; GRANT my_aq_user_role TO aquser;

20 Wilfried Mausz Creating a queue Payload Queue table Queue

21 Wilfried Mausz Payload New datatype (object) Execute permissions on that type CREATE TYPE queue_message_type AS OBJECT( no NUMBER, title VARCHAR2(30), text VARCHAR2(2000) ); GRANT EXECUTE ON queue_message_type TO my_aq_user_role;

22 Wilfried Mausz Create queue Create queue table EXEC DBMS_AQADM.CREATE_QUEUE_TABLE( queue_table => 'queue_message_table', queue_payload_type => aqadm.queue_message_type');

23 Wilfried Mausz Create queue Create queue on queue table Start queue EXEC DBMS_AQADM.CREATE_QUEUE( queue_name => 'message_queue', queue_table => 'queue_message_table'); EXEC DBMS_AQADM.START_QUEUE( queue_name => 'message_queue');

24 Wilfried Mausz Using the queue Create message Enqueue Dequeue

25 Wilfried Mausz Using the queue Connect as queue user Create message (payload type) Enqueue message Dequeue message queue payload enqueue dequeue

26 Wilfried Mausz Using the queue (write) DECLARE queue_options DBMS_AQ.ENQUEUE_OPTIONS_T; message_properties DBMS_AQ.MESSAGE_PROPERTIES_T; message_id RAW(16); my_message aqadm.queue_message_type; BEGIN my_message := aqadm.queue_message_type( 1, 'This is a sample message', 'This message has been posted on ' || TO_CHAR(SYSDATE,'DD.MM.YYYY HH24:MI:SS')); DBMS_AQ.ENQUEUE( queue_name => 'aqadm.message_queue', enqueue_options => queue_options, message_properties => message_properties, payload => my_message, msgid => message_id); COMMIT; END;

27 Wilfried Mausz Using the queue (read) SET SERVEROUTPUT ON; DECLARE queue_optionsDBMS_AQ.DEQUEUE_OPTIONS_T; message_propertiesDBMS_AQ.MESSAGE_PROPERTIES_T; message_idRAW(2000); my_messageaqadm.queue_message_type; BEGIN DBMS_AQ.DEQUEUE( queue_name => 'aqadm.message_queue', dequeue_options => queue_options, message_properties => message_properties, payload => my_message, msgid => message_id ); COMMIT; DBMS_OUTPUT.PUT_LINE('Dequeued no: ' || my_message.no); DBMS_OUTPUT.PUT_LINE('Dequeued title: ' || my_message.title); DBMS_OUTPUT.PUT_LINE('Dequeued text: ' || my_message.text); END;

28 Wilfried Mausz Timing message Change delay of the message property Delay in seconds BEGIN my_message := aqadm.queue_message_type( 1, 'This is a sample message', 'This message has been posted on ' || TO_CHAR(SYSDATE,'DD.MM.YYYY HH24:MI:SS')); message_properties.delay := 60; DBMS_AQ.ENQUEUE( queue_name => 'aqadm.message_queue', enqueue_options => queue_options, message_properties => message_properties, payload => my_message, msgid => message_id); queue payload ?

29 Wilfried Mausz Conclusion Powerful mechanism to transport messages inside the database, as well to external programs Reduces database lookups for data export Asynchronous processing of data (fire and forget) Timing and priority possible Availible in PL/SQL  useable in every programming environment

30 Wilfried Mausz Literature http://www.unix.org.ua/orelly/oracle/bipack/ch05_01.htm g.html, http://www.akadia.com/services/ora_advanced_queuein g.html http://en.wikipedia.org/wiki/Queue

31 Wilfried Mausz Table of images Queue, h19/ch19.html, h19/ch19.html Overview Advanced Queues 9i_overview.html, i_overview.html


Download ppt "Wilfried Mausz Oracle Advanced Queueing. Wilfried Mausz Agenda Queues Models Requirements Creating and using a queue Live demos –Point-to-point queue."

Similar presentations


Ads by Google