Skip Headers

Oracle® Objects for OLE Developer's Guide
10g Release 1 (10.1)

Part Number B10118-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

Example: Enqueuing Messages

NOTE: The following code snippets serve as models for dequeuing messages.

A complete AQ sample can be found in \OO4O\VB\SAMPLES\AQ.

Enqueuing messages of type RAW

'Create an OraAQ object for the queue "DBQ"

Dim Q as OraAQ

Dim Msg as OraAQMsg

Dim OraSession as OraSession

Dim DB as OraDatabase

Set OraSession = CreateObject("OracleInProcServer.XOraSession")

Set DB = OraSession.OpenDatabase("mydb", "scott/tiger" 0&)

Set Q = DB.CreateAQ("DBQ")

'Get a reference to the AQMsg object

Set Msg = Q.AQMsg

Msg.Value = "Enqueue the first message to a RAW queue."

'Enqueue the message

Q.Enqueue

'Enqueue another message.

Msg.Value = "Another message"

Q.Enqueue

'Enqueue a message with nondefault properties.

Msg.Priority = ORAQMSG_HIGH_PRIORITY

Msg.Delay = 5

Msg.Value = "Urgent message"

Q.Enqueue

Msg.Value = "The visibility option used in the enqueue call is

ORAAQ_ENQ_IMMEDIATE"

Q.Visible = ORAAQ_ENQ_IMMEDIATE

Msgid = Q.Enqueue

'Enqueue Ahead of message Msgid_1

Msg.Value = "First Message to test Relative Message id"

Msg.Correlation = "RELATIVE_MESSAGE_ID"

Msg.delay = ORAAQ_MSG_NO_DELAY

Msgid_1 = Q.Enqueue

Msg.Value = "Second message to test RELATIVE_MESSAGE_ID is queued

ahead of the First Message "

Q.RelMsgId = Msgid_1

Msgid = Q.Enqueue

Enqueuing messages of Oracle object types

'Prepare the message. MESSAGE_TYPE is a user defined type

' in the "AQ" schema

Set OraMsg = Q.AQMsg(23, "MESSAGE_TYPE","SCOTT")

Set OraObj = DB.CreateOraObject("MESSAGE_TYPE")

OraObj("subject").Value = "Greetings from OO4O"

OraObj("text").Value = "Text of a message originated from OO4O"

Msgid = Q.Enqueue