例
注意: 次のサンプル・コードは、メッセージ・デキューの標準的な例ですが、そのままでは実行できません。完全なAQサンプルは、 |
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
Oracleオブジェクト型のメッセージのエンキュー
'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