MSMQ 事务属性的设置

MSMQ队列的事务属性的设置关系到使用哪种消息发送方式

public static MessageQueue Create(string path, bool transactional);

当创建队列为事务性队列,那么发送消息需要指定为Automatic或Single模式方可成功(否则更严重的是发送失败但又不报异常,问题很不好找);

queue.Send(msg, MessageQueueTransactionType.Automatic) 成功

queue.Send(msg, MessageQueueTransactionType.Single) 成功

queue.Send(msg) 失败

当创建队列为非事务性队列,那么发送消息不能指定为Automatic或Single模式方可成功(否则更严重的是发送失败但又不报异常,问题很不好找)。

queue.Send(msg, MessageQueueTransactionType.Automatic) 失败

queue.Send(msg, MessageQueueTransactionType.Single) 失败

queue.Send(msg) 成功

 

你可能感兴趣的:(事务)