DequeueArray Error

DequeueArray Error

Postby kuhnj@pjm.com » Mon 19 Oct 2009 12:55

We are try to Dequeue an array of messages with custom payload types. Dequeue works fine but DequeueArray generates the following exception: Message = "Collection type for payload data type MOI_MKTQUEUEMSG does not exist." Can you direct me to an example of how to do this?
kuhnj@pjm.com
 
Posts: 3
Joined: Fri 16 Oct 2009 16:18

Postby Shalex » Tue 20 Oct 2009 14:43

Please make sure that you have set the PayloadArrayTypeName property of your OracleQueue you used for dequeuing.
Code: Select all
void EnDeQueue() {
  string connString = "server=***;uid=***;pwd=***;";
  string queueName = "myQueue";
  int batchSize = 20;
  //EnQueue
  using (OracleConnection connection = new OracleConnection(connString)) {
    connection.Open();

    OracleCommand oracleCommand = new OracleCommand("CREATE OR REPLACE TYPE my_type AS OBJECT (id NUMBER(4), " + "mestext VARCHAR2(80));", connection);
    oracleCommand.ExecuteNonQuery();
    oracleCommand.CommandText = "CREATE OR REPLACE TYPE my_type_array is VARRAY(20) OF my_type;";
    oracleCommand.ExecuteNonQuery();

    OracleQueueTable oracleQueueTable = new OracleQueueTable("QUEUE_TABLE_MESSAGE", connection);
    oracleQueueTable.Options.PayloadTypeName = "my_type";
    oracleQueueTable.CreateQueueTable();
    OracleQueueAdmin oracleQueueAdmin = new OracleQueueAdmin(queueName, "QUEUE_TABLE_MESSAGE", connection);
    oracleQueueAdmin.CreateQueue();
    oracleQueueAdmin.StartQueue();
    OracleQueue oracleEnqueueQueue = new OracleQueue(queueName, connection);
    OracleObject obj = new OracleObject("my_type", connection);
    for (int i = 0; i < 10; i++) {
      obj["id"] = i;
      obj["mestext"] = "hello!";
      oracleEnqueueQueue.Enqueue(obj);
    }
    connection.Close();
  }

  //DeQueue
  using (OracleConnection connection = new OracleConnection(connString)) {
    connection.Open();
    using (OracleQueue oracleDequeueQueue = new OracleQueue(queueName, connection)) {

      //setting the array type name for object type queues
      oracleDequeueQueue.PayloadArrayTypeName = "my_type_array";

      oracleDequeueQueue.DequeueOptions.Navigation = OracleQueueNavigation.FirstMessage;
      oracleDequeueQueue.DequeueOptions.DeliveryMode = OracleQueueDeliveryMode.Persistent;
      oracleDequeueQueue.DequeueOptions.Visibility = OracleQueueVisibility.Immediate;
      oracleDequeueQueue.DequeueOptions.DequeueMode = OracleQueueDequeueMode.Remove;
      oracleDequeueQueue.DequeueOptions.WaitTimeout = 0;
      OracleQueueMessage[] qMsgs;
      try {
        qMsgs = oracleDequeueQueue.DequeueArray(batchSize);
      }
      catch (OracleException e) {
        if (e.Code == 25228) {
          Console.WriteLine("No messages to dequeue");
        }
        throw (e);
      }
    }
  }
}
Shalex
Devart Team
 
Posts: 7391
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle