Example code for asyncroneous notification with OracleQueue

Example code for asyncroneous notification with OracleQueue

Postby ddeml77 » Fri 13 Jun 2008 08:52

Hello,

I am looking for an example code on how to properly dequeue a message in the OracleQueue.OnMessage handler.
  • Is OracleQueue thread safe so that concurrent invokes of Dequeue() (from the OnMessage handler) are supported?
  • Is it asserted that OnMessage is invoked for each and every received message?
  • Is there a possibility to invoke OracleQueue.Dequeue() in nonblocking mode or is it possible to check for pending messages?
  • The OracleQueueMessageEventArgs only provides OracleQueueMessageProperties, but not the OracleQueueMessage itself. What is the best way to fetch the acutal OracleMessage that raises the OnMessage event?

Should it be more like this:
Code: Select all
private void OracleQueue_OnMessage(object sender,
    OracleQueueMessageEventArgs args)
{
    OracleQueue oracleQueue = (OracleQueue)sender;
    //We tweack the DequeueOptions of the oracle queue to only dequeue
    //the message of out interest
    OracleQueueMessageId originalMessageId =
        oracleQueue.DequeueOptions.MessageId;
    oracleQueue.DequeueOptions.MessageId = args.MessageId;
    OracleQueueMessage message = oracleQueue.Dequeue();
    oracleQueue.DequeueOptions.MessageId = originalMessageId;
    //proceed with message from here
}


...or should it be more like this:
Code: Select all
private void OracleQueue_OnMessage(object sender,
    OracleQueueMessageEventArgs args)
{
    OracleQueue oracleQueue = (OracleQueue)sender;
    //Dirty HACK because OracleQueueDequeueOptions does not implement ICloneable
    OracleQueueDequeueOptions dequeueOptions = (OracleQueueDequeueOptions)
        typeof(OracleQueueDequeueOptions).GetMethod("MemberwiseClone",
        BindingFlags.NonPublic | BindingFlags.Instance, null,
        Type.EmptyTypes, null).Invoke(oracleQueue, null);
    dequeueOptions.MessageId = args.MessageId;
    OracleQueueMessage message = oracleQueue.Dequeue(dequeueOptions);
    //proceed with message from here
}


...or more like this?
Code: Select all
private void OracleQueue_OnMessage(object sender,
    OracleQueueMessageEventArgs args)
{
    OracleQueue oracleQueue = (OracleQueue)sender;
    //Ignore args.MessageId because it cannot be decently handeled
    //We just get any next message and dont care which message it has
    OracleQueueMessage message = oracleQueue.Dequeue();
    //proceed with message from here
}


Thanks in advance for any help!

Greetings - Richie
ddeml77
 
Posts: 14
Joined: Thu 14 Jun 2007 08:56
Location: Germany

Postby Alexey.mdr » Tue 17 Jun 2008 13:59

Hello,

Please see "Advanced Queuing Technology Support" topic in the product help.
There are several samples there.

Regards,
Alexey.
Alexey.mdr
 
Posts: 729
Joined: Thu 13 Dec 2007 10:24


Return to dotConnect for Oracle