简体   繁体   English

msmq是否确保事务队列上的数据完整性?

[英]Does msmq ensure data integrity on transactional queues?

I'm using MSMQ to transfer a byte array. 我正在使用MSMQ传输byte数组。

The formatter is a BinaryMessageFormatter . 格式化程序是BinaryMessageFormatter

The destination queue is a private one, and I'm using direct TCP communication. 目标队列是私有队列,我正在使用直接TCP通信。

The destination machine is in a different LAN, I access it by its external IP address. 目标计算机位于不同的LAN中,我通过其外部IP地址访问它。

There's a firewall which routs the incoming TCP communication to the actual destination machine (port forwarding). 有一个防火墙可以将传入的TCP通信路由到实际的目标机器(端口转发)。

So the system's architecture looks like this: 所以系统的架构如下所示:

[source machine] --> [destination firewall] --> [destination machine]

I've been using the system for a few months, and all went fine. 我一直在使用这个系统几个月,一切都很顺利。

Recently we experienced a firewall failure. 最近我们遇到了防火墙故障。

Apparently, this caused to data corruption: 显然,这导致了数据损坏:

While the queue is transactional, and the message, according to MSMQ, was successfully delivered to the destination machine, the message's content was corrupted. 虽然队列是事务性的,并且根据MSMQ,消息已成功传递到目标计算机,但消息的内容已损坏。

That is, the code for reading the message from the queue raised an exception: 也就是说,从队列中读取消息的代码引发了异常:

try
{
    var message = queue.Receive(readTimeout, transaction);
    if (message != null)
    {
        data = (byte[]) message.Body; // this line raises an exception
        return true;
    }
}
catch (Exception e)
{
    Logger.Error("error reading queue", e);
}

I had to delete a few messages from (top of) the queue, and then the system got back to normal. 我不得不从队列(顶部)删除一些消息,然后系统恢复正常。

My question: 我的问题:

Assuming that it was only the firewall's failure that caused this, and knowing it's a transactional queue, how come the message was considered to be delivered? 假设只有防火墙的故障导致了这种情况,并且知道它是一个事务性队列,那么为什么消息被认为是被传递的?
Isn't MSMQ executing some kind of a checksum to ensure data integrity on transactional queues? MSMQ是否正在执行某种校验和以确保事务队列上的数据完整性?

在数据完整性和完整性方面,它目前看起来像MSMQ完全“信任”TCP层。

This is just a guess, but I think the Distributed Transaction Coordinator (DTC) might have troubles here. 这只是猜测,但我认为分布式事务处理协调器 (DTC)可能会遇到麻烦。 As the name implies, the DTC is responsible for handling the transactions that involve multiple system in a network. 顾名思义,DTC负责处理涉及网络中多个系统的事务。

What I could imagine in your scenario, is that the transactions cannot be correctly managed over your different LANs. 我在您的方案中可以想象的是,无法通过不同的LAN正确管理事务。

My suggestion to you is to check the configurations of the involved DTC instances in both networks if there are option to enable the communication between them and/ or research if the firewall needs to be set up for to allow DTC communication. 我的建议是检查两个网络中涉及的DTC实例的配置,如果有选项可以启用它们之间的通信和/或研究是否需要设置防火墙以允许DTC通信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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