I want to take message from one queue and send it to database. I want to do it only if it\'s in specific format.
If i use Receive
method directly and some e
This is the same approach that I take when manually dequeuing message one at a time and I've not come across any issues with it.
The one thing that you do not appear to dealing with is how to handle a message on the queue that does not have the required format. Is your intention to leave it on the queue? If so, you might end up with a very large queue and have all sorts of issues with peeking at messages further up the queue that have not yet been expected. It would appear to make more sense to also de-queue those messages that do not have the required format and store them elsewhere if they cannot be deleted.
"If i use Receive method directly and some exception occurs while accessing Body of the Message, I lose the message since Receive method of the MessageQueue removes the message from the queue."
You should be using transactional receives so that the message returns to the queue when/if the transaction aborts.
Cheers
John Breakwell