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 />

AS<br />

msgprop dbms_aq.message_properties_t;<br />

enqopt dbms_aq.enqueue_options_t;<br />

enq_msgid RAW(16);<br />

payload adtmsg;<br />

BEGIN<br />

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

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

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

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

/* Payload is NOT NULL: */<br />

payload := adtmsg(1, 'Logging Off');<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 />

/<br />

/* If there is a login at APP1, enqueue a message into 'login_logoff' with<br />

correlation 'LOGIN': */<br />

EXECUTE User_logon('APP1');<br />

/* If there is a logout at APP3, enqueue a message into 'login_logoff' with<br />

correlation 'LOGOFF' and payload adtmsg(1, 'Logging Off'): */<br />

EXECUTE User_logoff('App3');<br />

/* The OCI program which waits for notifications: */<br />

#include <br />

#include <br />

#include <br />

#include <br />

#ifdef WIN32COMMON<br />

#define sleep(x) Sleep(1000*(x))<br />

#endif<br />

/* LOGON / password: */<br />

static text *username = (text *) "OE";<br />

static text *password = (text *) "OE";<br />

/* The correlation strings of messages: */<br />

A Sample Application Using AQ 8-19

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

Saved successfully!

Ooh no, something went wrong!