Learner
Learner

Reputation: 4751

Adding Message to MessageQueue programmatically

I have the old 'non-transactional' queue (MessageQueue) which may have messages in it.

Now programatically, I want to: 1. Get the messages from old queue ----> this is done 2. Create new 'transactional' queue ---> this is also done 3. Copy messages from old message queue to new queue -----> How to do this? 4. Delete the old queue. --- > I can do it by calling Close(), then Dispose() for the old queue and the I can delete the queue using MessageQueue.Delete(). Is it right? And is it necessary to call Close and Dispose before deleting the queue?

Please guide me regarding questions in bold letters.

Upvotes: 0

Views: 371

Answers (1)

František Žiačik
František Žiačik

Reputation: 7614

You must read the contents of message from old queue and Send it to new queue as new message. There is no Copy method.

To delete a queue, you can use static method, so the Close / Dispose does not apply:

System.Messaging.MessageQueue.Delete(@"myMachine\MyQueue");

Upvotes: 1

Related Questions