BizTalk 消息会互相覆盖吗?

发布于 2024-10-09 18:21:55 字数 694 浏览 9 评论 0原文

我遇到了一种奇怪的情况,这种情况只出现在我正在处理的这个编排中。

我收到一条接收消息。我使用表达式形状并将其写入变量“xmlDoc”,以便我可以验证其中的内容。然后,我有一个消息分配形状,将 XML 字符串加载到变量“xmlDoc2”,并将该变量分配给第二条消息并将其写出来,以便我可以验证它。然后,我有另一个表达式形状并尝试再次写出第一条消息,它显然已被第二条消息信息替换。

它不是并行形状,并且消息分配仅构建第二条消息。在接收和我看到这个问题之间,我正在做一些决定形状并从接收消息构建其他消息。它们都工作正常并且不会覆盖任何内容(执行与我稍后尝试执行的过程相同的过程。)

有人以前见过这个或看到我遗漏的东西吗?

预计到达时间:这个过程有点像这样:

Send Message comes in
xmlDoc = Send Message
xmlDoc.OuterXml is written to a table
xmlDoc2 = "<root><xml></xml></root>"
Second Message = xmlDoc2
xmlDoc2.OuterXml is written to a table
xmlDoc = Send Message <-- What should happen
xmlDoc = Second Message <-- What is happening

I have an odd situation that has only come up in this one orchestration I'm working on.

I have a Receive message come in. I use an Expression shape and write it to a variable "xmlDoc" so I can verify what is in it. I then have a Message Assignment shape where I Load a string of XML to a variable "xmlDoc2" and assign that variable to a second message and write it out so I can verify it. I then have another Expression shape and attempt to write out the first message again and it's apparently been replaced with the second message information.

It's not in a Parallel shape, and the Message Assignment is only building the second message. Between the receive and where I'm seeing this issue, I'm doing a few Decide shapes and building other messages from the Receive message. They all work fine and don't overwrite anything (do the same processes as what I'm trying to do later.)

Anyone seen this before or see something I'm missing?

ETA: The process works a bit like this:

Send Message comes in
xmlDoc = Send Message
xmlDoc.OuterXml is written to a table
xmlDoc2 = "<root><xml></xml></root>"
Second Message = xmlDoc2
xmlDoc2.OuterXml is written to a table
xmlDoc = Send Message <-- What should happen
xmlDoc = Second Message <-- What is happening

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苄①跕圉湢 2024-10-16 18:21:55

我无法重现您的确切问题,但我已经接近了。我认为您的流程大纲中存在一些隐含的陈述,这对于我们了解到底发生了什么至关重要。无论如何,我认为您的 BizTalk 消息不会被覆盖,但 XmlDocument 变量会被覆盖。

我认为您可能已经被 Java 或 VB6 开发人员的基本困惑之一所困扰使用 C# 时遇到的背景。

C# 是一种托管语言

请记住,C# 是一种托管语言,因为它使用垃圾收集器来回收对对象的未使用引用。这里的关键词是参考

当您编写以下几行时:

xmlDoc2 = "<root><xml/></root>";
SecondMessage = xmlDoc2;

基本上,您有两个对相同内容的引用。即,两个引用 xmlDoc2SecondMessage 引用分配的字符串。

因此,根据您用于“写出”BizTalk 消息的 XML 内容的代码,您可能会覆盖一些引用。

此外,如果这种情况发生在构造形状的上下文中,您可能会无意中覆盖 BizTalk 消息本身的内容。

解决方案?

使用 BizTalk 时,此问题通常不会显现出来。我个人从未遇到过这个问题。

如果您使用表达式形状和作业形状的确切代码更新原始问题,我将使用更合适的指导更新此响应。

I could not reproduce your exact problem but I got close. I think there are some implied statements in your process outline that would be critical for us to understand what's really happening. In any case, I think your BizTalk messages do not get overwritten, but that the XmlDocument variables are.

I think you may have been hit by one of the fundamental confusions a developer coming from a Java or VB6 background encounters when working with C#.

C# is a Managed Language

Please, remember that C# is a managed language, in that it uses a garbage collector to reclaim unused references to objects. The key word here is Reference.

When you write the following lines:

xmlDoc2 = "<root><xml/></root>";
SecondMessage = xmlDoc2;

Basically, you have two references to the same content. Namely, two references xmlDoc2 and SecondMessage which refer to the assigned string.

So, depending upon the code you use to "write out" the XML content of your BizTalk messages, you may be overwriting some references.

Furthermore, if this happens in the context of a Construct shape, you may be inadvertently overwriting the content of the BizTalk message itself.

A Solution?

This problem does not usually manifest itself when working with BizTalk. I personally never encountered this issue.

If you update your original question with the exact code for both Expression shapes and the Assignment shape, I'll update this response with more appropriate guidance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文