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.
OracleQueue - Dequeue method timeout
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
Re: OracleQueue - Dequeue method timeout
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.fad wrote:In some case I need to stop the Dequeue method before timeout occur, how can I do it..?
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
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.
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
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.
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
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();
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