How to remove message from message queue (only if its well formatted)?

前端 未结 2 1907
别那么骄傲
别那么骄傲 2021-01-23 10:19

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

相关标签:
2条回答
  • 2021-01-23 10:37

    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.

    0 讨论(0)
  • 2021-01-23 10:54

    "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

    0 讨论(0)
提交回复
热议问题