MSMQ线程安全吗? [英] Is MSMQ thread safe?

查看:118
本文介绍了MSMQ线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个进程监视MSMQ队列.我想执行多步操作,例如先查看消息,然后根据某些条件接收消息.一条消息可能会通过多个进程的接收标准,因此一个以上的进程可能会尝试接收同一条消息.这些操作将是线程安全的吗?如果不是,我应该怎么做才能防止一个进程无法收到另一进程已经收到的消息?

I have multiple processes monitoring an MSMQ queue. I want to do multi-step operations like first peek the message and then based on some criteria receive the message. A single message may pass the receiving criteria of multiple processes so that more than one process may try to receive the same message. Will these operations be thread safe? If not what should I do to prevent one process from failing to receive the message that other process has already received?

推荐答案

操作本身是线程安全的.但是,如果执行多步操作,您可能会发现结果不一致(例如,偷看队列中是否有数据,然后调用以接收数据,只是发现不再存在).

The operations themselves are thread safe. However, if you perform a multi-step operation you may find that the results are not consistent (for example, peeking to see if data is in the queue, then calling to receive the data, only to discover it's not there any longer).

这篇关于MSMQ线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆