09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

General Features of <strong>Advanced</strong> <strong>Queuing</strong><br />

two events, the correlation of the message is LOGIN for logins and LOGOUT for<br />

logouts.<br />

The callback function counts the login/logout events for each application process.<br />

Note that the dispatcher process needs to connect to the database for registering the<br />

subscriptions only. The notifications themselves can be received while the process is<br />

disconnected from the database.<br />

PL/SQL (DBMS_AQADM Package): Example Code<br />

CONNECT oe/oe;<br />

/* Create the Object Type/ADT adtmsg */<br />

CREATE OR REPLACE TYPE adtmsg AS OBJECT (id NUMBER, data VARCHAR2(4000));<br />

/* Create the multiconsumer nonpersistent queue in OE schema: */<br />

EXECUTE dbms_aqadm.create_np_queue(queue_name => 'LOGON_LOGOFF',<br />

multiple_consumers => TRUE);<br />

/* Enable the queue for enqueue and dequeue: */<br />

EXECUTE dbms_aqadm.start_queue(queue_name => 'LOGON_LOGOFF');<br />

/* Nonpersistent Queue Scenario - procedure to be executed upon logon: */<br />

CREATE OR REPLACE PROCEDURE User_Logon(app_process IN VARCHAR2)<br />

AS<br />

msgprop dbms_aq.message_properties_t;<br />

enqopt dbms_aq.enqueue_options_t;<br />

enq_msgid RAW(16);<br />

payload RAW(1);<br />

BEGIN<br />

/* visibility must always be immediate for NonPersistent queues */<br />

enqopt.visibility:=dbms_aq.IMMEDIATE;<br />

msgprop.correlation:= 'LOGON';<br />

msgprop.recipient_list(0) := aq$_agent(app_process, NULL, NULL);<br />

/* payload is NULL */<br />

dbms_aq.enqueue(<br />

queue_name => 'LOGON_LOGOFF',<br />

enqueue_options => enqopt,<br />

message_properties => msgprop,<br />

payload => payload,<br />

msgid => enq_msgid);<br />

END;<br />

/* Nonpersistent queue scenario - procedure to be executed upon logoff: */<br />

CREATE OR REPLACE PROCEDURE User_Logoff(app_process IN VARCHAR2)<br />

8-18 <strong>Oracle</strong>9i Application Developer’s Guide - <strong>Advanced</strong> <strong>Queuing</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!