Monday, March 19, 2012

Deadlock in Queue

Hello!

I am running a basic SSB queue setup (more or less the Hello World example)and running into the following error message:

Transaction (Process ID 120) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

At first, I thought it was because I had the Initiator and Target Services on the same Queue, but I get this error even when I separate the two Services onto two Queues. This happens when I run more than one Target application receiving messages from the Target Queue.

Does anybody have any idea what could be happening here? Am I not allowed to set up more than one receiver?

Thanks --

Robert

OK, after reading a bit more, I think that I may have found the answer.

When I called RECEIVE, I wasn't specifying the conversation handle or conversation group ID. I changed my query to utilize the GET CONVERSATION GROUP statement to get the first conversation group ID on the receive Queue, then only RECEIVE the messages within the conversation group.

So far, I haven't had a deadlock, but I intend to leave this running for a while to see if it comes back. Does what I found seem like it would make sense or is there anything else that I may not be taking into account?

|||That makes perfect sense. whatever you receive off the queue is then locked (By conversation group) while you are handling it. If you have two receive processes running off the same queue if they try to process the same conversation group a deadlock will occur.

No comments:

Post a Comment