开发者

BizTalk messages overwriting each other?

开发者 https://www.devze.com 2023-02-02 04:07 出处:网络
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 veri

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 Assi开发者_开发技巧gnment 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号