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();
}
}