tags:

views:

138

answers:

0

I have a transactional message queue on Server 2003. It receives messages from several remote machines. Each day, an executable runs which moves those messages from one queue to another on the same machine, however, the executable is processing several hundred messages and then throws an "Invalid Handle was passed to the function" error.

The original code went something like this.(pseudo code)

msgcount = GetMessageCount()
count = 1
msgEnumerator = queue.GetMessageEnumerator2 

while(msgEnumerator.moveNext())
{
    if count> msgcount
       break;
    trans = new transaction
    try
    {
        message = queue.ReceiveById(msgEnumerator.ID, trans)

        otherQueue.send(message)
    }
    catch
    {
        trans.abort
    }
    finally
    {
        count++
    }

}

The error is thrown inside ReceiveById when GetCurrent() is called. I've tried altering the receive to just use Receive(timeout,cursor,transaction), but the same thing happened.

Thanks for looking