Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MSMQ Cursor Issue

66 views
Skip to first unread message

Doogie

unread,
Apr 5, 2007, 10:46:53 AM4/5/07
to
Hi,

We have a component that was written in VB6 that is triggered when a
message goes to one of our MS queue's and processes the messages
(according to varying business logic).

Recently we ran into a situation where if we shoot off multiple
messages to this queue at the same time we get the following error:

The message at which the cursor is currently pointing was removed
from the queue by another process or by
another call to MQReceiveMessage without the use of this cursor

My theory on this is as follows. Say we send 5 messages. One
instance of this component (Instance A) grabs those five and tries to
process them. However, while processing the first message (Message
1), for some reason (I'm not sure what that reason would be at this
point) another instance of this component (Instance B) goes out and
grabs what's in the queue (now 4 messages) and tries to process them
as well. Instance B processes the first message it has (Message 2)
and so when Instance A tries to process Message 2 as well it fails
because it's not there.

I'm not sure where to look in the code to verify my theory - or even
if that theory is sound. Does anyone have suggestions here? Would it
help to post some of the code (it's old "spaghetti" code so it may be
a bit confusing to read).

Yoel Arnon

unread,
Apr 5, 2007, 2:43:57 PM4/5/07
to
Hello,
Yes, your theory sounds right. Allow me to put it into MSMQ terms:

A1. Process A opens the queue and gets an MSMQQueue object (Since you
mentioned that the program was written in VB6, I assume it uses the MSMQ COM
Interface). Let's call it QhA.

A2. Process A calls QhA.PeekCurrent and gets a message. It may then calls
QhA.PeekNext several times till it gets a message that it is interested in.
Let's call this message M1.

A3. Process A removes the message from the queue by calling
QhA.ReceiveCurrent.

Now assume that process B has the exact same algorithm, using steps B1, B2 &
B3 that are the same as A1, A2 & A3. Its queue handle is QhB.

Now, assume that both processes completed step 2 (A2 & B2) and they both
hold the same message M1. If B3 is called first, then QhB.ReceiveCurrent
will work, and step A3 (QhA.ReceiveCurrent) will fail with the error you
saw. If A3 is called first, B3 will fail with that error.

From my experience, most MSMQ applications don't really need cursors (or
using PeekCurrent, PeekNext & ReceiveCurrent) and could manage quite well
with just Receive & Peek. This may or may not be the situation in your case.

Yes, posting the code can help. Also feel free to contact me directly - I
may be able to help you find the right approach.

Hope that helps,
Yoel Arnon
www.msmq.biz

"Doogie" <dnlw...@dtgnet.com> wrote in message
news:1175784413.4...@w1g2000hsg.googlegroups.com...

behrad.s...@gmail.com

unread,
Aug 2, 2018, 2:38:33 PM8/2/18
to
any update on this one? (12 years later). I have the same issue with an old legacy system. IT happens when it checks the queue from another machine.
0 new messages