'OracleAQRnd.db_Message_type2::text::OracleObjectMappingAttribute' cannot be set to an invalid value of 'text'

823 views Asked by At

I need to do Enqueue and Dequeue messages using UDT in oracle advanced queue in c#. I am using following code.

UDT:

CREATE OR REPLACE TYPE APPS_GLOBAL.db_Message_type2 as object ( text VARCHAR2(4000 CHAR), text1 number);

C#:

' [OracleCustomTypeMapping("APPS_GLOBAL.DB_MESSAGE_TYPE2")] class db_Message_type2 : IOracleCustomType, INullable { private string _text; private decimal _text1; private bool _isNull;

    public db_Message_type2()
    {
        _text = "iDontKnow";
        _text1 = 30;
    }

    public db_Message_type2(string text, decimal text1)
    {
        _text = text;
        _text1 = text1;
    }

    [OracleObjectMapping("text")]
    public string text
    {
        get { return this._text; }
        set { this._text = value; }
    }

    [OracleObjectMapping("text1")]
    public decimal text1
    {
        get { return this._text1; }
        set { this._text1 = value; }
    }

    public bool IsNull { get { return this._isNull; } }
    public void FromCustomObject(OracleConnection con, IntPtr pUdt)
    {
        OracleUdt.SetValue(con, pUdt, "text", this._text);
        OracleUdt.SetValue(con, pUdt, "text1", this._text1);
    }

    public void ToCustomObject(OracleConnection con, IntPtr pUdt)
    {
        text = (string)OracleUdt.GetValue(con, pUdt, "text");
        text1 = (decimal)OracleUdt.GetValue(con, pUdt, "text1");
    }

    public static db_Message_type2 Null
    {
        get { return new db_Message_type2 { _isNull = true }; }
    }
}

'

[OracleCustomTypeMappingAttribute("APPS_GLOBAL.DB_MESSAGE_TYPE2")]
public class QueueMessageTypeFactory : IOracleCustomTypeFactory
{
    public IOracleCustomType CreateObject()
    {
        var result = new db_Message_type2("iDontKnow anything about AQ", 50);
        return result;
    }
}



class Program
{
    static void Main(string[] args)
    {
        EnqueueUDT();
        Console.ReadLine();
    }

    static void EnqueueUDT()
    {
        try
        {
            string _connstring = "myConnectionString";

            OracleConnection _connObj = new OracleConnection(_connstring);

            _connObj.Open();

            OracleTransaction _txn = _connObj.BeginTransaction();
            OracleAQQueue _queueObj = new OracleAQQueue("APPS_GLOBAL.db_temp_adv_queue3", _connObj, OracleAQMessageType.Udt, "APPS_GLOBAL.DB_MESSAGE_TYPE2");

            OracleAQMessage _msg = new OracleAQMessage();

            _msg.Payload = new db_Message_type2 { text = "Custom", text1 = 5 };

            // Enqueue the message
            //_queueObj.EnqueueOptions.Visibility = OracleAQVisibilityMode.Immediate;
            //_queueObj.EnqueueOptions.DeliveryMode = OracleAQMessageDeliveryMode.Persistent;

            //_queueObj.Enqueue(_msg);
            _queueObj.Enqueue(_msg, new OracleAQEnqueueOptions { DeliveryMode = OracleAQMessageDeliveryMode.Persistent, Visibility = OracleAQVisibilityMode.Immediate });

            _txn.Commit();
            _queueObj.Dispose();
            _connObj.Close();
            _connObj.Dispose();
            _connObj = null;
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message.ToString());
        }
    }
}

I am not able to understand where i have done wrong.

0

There are 0 answers