Hi all,
I wan to ask of receiving message from the MSMQ. Is it possible to recieve message from any place or only from the head of the queue.
I want to pull messages from the queue not according to the first message in the head of the queue, I want to pull from a certain Id of a message.
Regards... | | Wasim | You can definitely do this. Take a look at System.Messaging.MessageQueue, especially MessageQueue.ReceiveById(string id). Other useful methods are ReceiveByCorrelationId, ReceiveByLookupId, Peek, PeekById, ReceiveByCorrelationId, and PeekByLookupId. You can find code snippets in the documents linked above. Here's an example from http://msdn2.microsoft.com/library/0t877y0k(en-us,vs.80).aspx:
// Connect to a queue on the local computer. | | James Kovacs | Hi, Ok!, but can I decide the message ID, in your example I have to know the message ID to resieve it by ID. My target is: I want clients to recieve the message by their Id, they don't know what is the ID of the message suits to each of them.
For example, I insert 3 messages to the queue (The first message to client 1,..). I want the three clients to recieve the messages that belong to each one of them. Maybe client 2 peek on the queue before client 1, So how can I tell hime to recieve the second message.
Regards... | | Wasim | You would have to program each client to peek through the queue looking for the messages that it should be receiving and then remove it.
Another option would be to set up a separate queue for each one. If you don't want your sender(s) to know that there are multiple queues, you could have a single public (or private) queue that is the main receiver of messages. You have a component listening on the queue and distributing messages to 3 private queues, one for each client in your example above.
*** Mark the best replies as answers! || Blog: http://www.jameskovacs.com *** | | James Kovacs |
|