| Devart.Data.Oracle Namespace : OracleQueue Class |
Represents Oracle Streams Advanced Queuing (AQ).
For a list of all members of this type, see OracleQueue members.
Devart.Data.Oracle.OracleQueue
[Visual Basic]
Public Class OracleQueue
Inherits Component
Implements IComponent , ISupportInitialize , IDisposable [C#]
public class OracleQueue : Component , IComponent , ISupportInitialize , IDisposable This class provides an interface for using queues: adding, deleting messages, listing queues. It is not to be used for administration of queues and queue tables, or for permissions management. For these purposes the OracleQueueAdmin and OracleQueueTable components should be used.
This class is available only in Professional and Developer Editions. It is not available in Standard and Mobile Editions.
The following example demonstrates usage of OracleQueue, OracleQueueAdmin, OracleQueueTable, OracleQueueTableOptions, and OracleQueueMessage classes. For detailed description of advanced queuing and more samples, refer to the Advanced Queuing Technology article.
[C#]
static void Main(string[] args)
{
using (OracleConnection oracleConnection = new OracleConnection(
"User Id=system;Password=manager;Server=ora;Direct=False;")) {
oracleConnection.Open();
OracleCommand oracleCommand = new OracleCommand(
"CREATE OR REPLACE TYPE message AS OBJECT (nickname VARCHAR2(15), " +
"mestext VARCHAR2(80));", oracleConnection);
oracleCommand.ExecuteNonQuery();
OracleQueueTable oracleQueueTable = new OracleQueueTable("QUEUE_TABLE_MESSAGE", oracleConnection);
oracleQueueTable.Options.PayloadTypeName = "message";
oracleQueueTable.CreateQueueTable();
OracleQueueAdmin oracleQueueAdmin = new OracleQueueAdmin("MESSAGE_QUEUE",
"QUEUE_TABLE_MESSAGE", oracleConnection);
oracleQueueAdmin.CreateQueue();
oracleQueueAdmin.StartQueue();
OracleQueue oracleEnqueueQueue = new OracleQueue("MESSAGE_QUEUE", oracleConnection);
OracleObject mes = new OracleObject("message", oracleConnection);
mes["nickname"] = oracleConnection.UserId;
mes["mestext"] = "Hello, world!";
oracleEnqueueQueue.Enqueue(mes);
OracleQueue oracleDequeueQueue = new OracleQueue("MESSAGE_QUEUE", oracleConnection);
OracleQueueMessage msg = oracleDequeueQueue.Dequeue();
if (msg != null && msg.ObjectPayload != null) {
Console.WriteLine(msg.ObjectPayload["nickname"]);
Console.WriteLine(msg.ObjectPayload["mestext"]);
}
oracleQueueAdmin.StopQueue();
oracleQueueAdmin.DropQueue();
oracleQueueTable.DropQueueTable();
oracleConnection.Close();
}
} [Visual Basic]
Sub Main()
Using oracleConnection As New OracleConnection("User Id=system;Password=manager;Server=ora;Direct=False;")
oracleConnection.Open()
Dim oracleCommand As New OracleCommand("CREATE OR REPLACE TYPE message " & _
"AS OBJECT (nickname VARCHAR2(15), mestext VARCHAR2(80));", oracleConnection)
OracleCommand.ExecuteNonQuery()
Dim oracleQueueTable As New OracleQueueTable("QUEUE_TABLE_MESSAGE", oracleConnection)
oracleQueueTable.Options.PayloadTypeName = "message"
oracleQueueTable.CreateQueueTable()
Dim oracleQueueAdmin As New OracleQueueAdmin("MESSAGE_QUEUE", _
"QUEUE_TABLE_MESSAGE", oracleConnection)
oracleQueueAdmin.CreateQueue()
oracleQueueAdmin.StartQueue()
Dim oracleEnqueueQueue As New OracleQueue("MESSAGE_QUEUE", oracleConnection)
Dim mes As New OracleObject("message", oracleConnection)
mes.Item("nickname") = oracleConnection.UserId
mes.Item("mestext") = "Hello, world!"
oracleEnqueueQueue.Enqueue(mes)
Dim oracleDequeueQueue As New OracleQueue("MESSAGE_QUEUE", oracleConnection)
Dim msg As OracleQueueMessage = oracleDequeueQueue.Dequeue()
If ((Not msg Is Nothing) AndAlso (Not msg.ObjectPayload Is Nothing)) Then
Console.WriteLine(msg.ObjectPayload.Item("nickname"))
Console.WriteLine(msg.ObjectPayload.Item("mestext"))
End If
oracleQueueAdmin.StopQueue()
oracleQueueAdmin.DropQueue()
oracleQueueTable.DropQueueTable()
oracleConnection.Close()
End Using
End SubOracleQueue Members | Devart.Data.Oracle Namespace | OracleQueueAdmin Class | OracleQueueTable Class
© 2002 - 2013 Devart. All Rights Reserved.