Enqueue (OraAQ) Method

Applies To

OraAQ Object

Description

Enqueues the message (OraAQMsg) contained in this object.

Usage

Msgid = Q.Enqueue

Remarks

On success, this method returns the message identifier as an array of bytes. Otherwise, it returns an empty array (null).

Examples

Note:

The following code samples are models for enqueuing messages, but cannot be run as is.

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

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 non-default 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