简体   繁体   中英

NetMsmqBinding losing messages when closing

I have been testing the NetMsmqBinding of WCF with a non-transactional queue. I have found that the service, the part that reads from the queue, will occasionally lose a message when it is closed.

For example, if I have a queue with messages of the numbers 1 - 10, and allow it to read the first five messages (1, 2, 3, 4, 5) before restarting, then the rest of the messages I might get are (7, 8, 9, 10). '6', the message it was going to receive before the service has closed is lost.

Is this because I'm using a non-transactional queue? Is there any way to prevent these messages getting lost without going transactional?

Thanks

If you are unable to use transactional queues then another solution to prevent loss of messages is to run one or more redundant queuing channels in unison.

What this means is that you send the message not once, but N times. Each message is then processed N times concurrently, and the net result should be that no messages are dropped.

The reason this works is that even though each processing channel could drop the occasional message, it's unlikely that all N processing channels would drop the same message.

The only thing you have to make sure is that your system can handle the added volume and can handle the messages idempotently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM