Page 1 of 1
OracleQueue - Dequeue method timeout
Posted: Fri 19 Jun 2015 12:24
by fad
Hi,
I'm using OracleQueue object with DequeueOptions.WaitTimeout = 30.
When I call OracleQueue.Dequeue method, the code returns after 30 seconds if the queue is empty.
In some case I need to stop the Dequeue method before timeout occur, how can I do it..?
Best regards,
Fad.
Re: OracleQueue - Dequeue method timeout
Posted: Mon 22 Jun 2015 12:34
by Pinturiccio
fad wrote:In some case I need to stop the Dequeue method before timeout occur, how can I do it..?
dotConnect for Oracle does not allow you to stop the Dequeue method execution, and you have to wait until it complete its execution or wait for the interval, specified in the DequeueOptions.WaitTimeout property.
We will analyze the possibility of implementing asynchronous execution for Enqueue and Dequeue methods but there is no timeframe.
As a workaround, you can execute the Dequeue method in a separate thread, and terminate this thread when you need to stop this method. You can use the BackgroundWorker class for this. For more information, please refer to
https://msdn.microsoft.com/en-us/librar ... 10%29.aspx
Re: OracleQueue - Dequeue method timeout
Posted: Wed 24 Jun 2015 07:59
by fad
Hi,
Ok, I've executed Dequeue method in a separate Thread.
To stopping Dequeue method I must call Thread.Abort method.
I'm looking forward to hearing from you news about asynchronous execution for Enqueue and Dequeue methods.
Best regards,
Fad.
Re: OracleQueue - Dequeue method timeout
Posted: Wed 15 Jul 2015 22:37
by mrbig
Don't do thread abort to stop a sleeping dequeue. This will not work. The thread will not stop.
You should handle the timeout in a try catch block, eg.
Code: Select all
OracleQueueDequeueOptions myDequeueOptions = new OracleQueueDequeueOptions();
OracleQueue oracleDequeueQueue = new OracleQueue("DQ_SERVERMESSAGEQUEUE", myOracleConnection);
oracleDequeueQueue.DequeueOptions.WaitTimeout = 60;
OracleQueueMessage msg = null;
try
{
msg = oracleDequeueQueue.Dequeue();
}
catch (OracleException ex)
{
if (ex.Code == 25228)
{
logger.Debug("Queue timeout...");
}
else
throw ex;
}
myOracleConnection.Close();
Remember you should also handle if oracle disappear during the time the code is sleeping in the dequeue i.e. if oracle disapears, connection lost, database crash, etc. If the connection is lost the dequeue function never returns.
You should have another thread checking if dequeue takes longer than 30 secs (in this example) and if it does, you should abort the thread and close and reopen a new connection to the database.
regards
/Klaus