Post by emyanyone knows why actually
the microsoft didn't provide the method to delete a
specific message
in a queue.
Partly I think the answer depends on exactly what you ean
by "a method to delete a specific message".
As Doron already posted, you can delete a message by doing
a Receive. If you are asking why there isn't a function
called MQDeleteMessage that takes similar parameters to
Receive then I'd say its because Receive already does that
and there's no need for a second function that duplicates
the capability.
On the other hand, if you are asking why there isn't an
MQDeleteMessage function with some different set of
parameters then I guess I'd ask what set of parameters you
think it would take? If those parameters are based on
message proeprties, then you have to have Peeked your way
to the message to know what those property values are, so
again receive could delete the message.
If that set of parameters were based on the contents of
the message body, then I'd say the reason there isn;t such
a function is that MSMQ itself is designed to be pretty
much ignorant of the contents of a message body - only the
sender and receiver need to know how the message body is
laid out. That's perhaps slightly less true in
SYSTEM.MESSAGING with the various formatters around, but
still it is the case that MSMQ itself doesn't look at the
body contents.
Another way of looking at this would be to say that MSMQ
is about managing queues and messages in queues and most
of the MSMQ design is focused on processing messages from
the front of the queue one at a time. Peek and cursors
etc give you some additional flexibility about how and
when you remove messages from a queue but the queue is
really still supposed to be a queue - not an arbitrary
collection of messages that can be randomly accessed and
randomly deleted.
That's my two cents worth anyway.