Friday, May 09, 2008

Endless XmlDisassembler

This is a curious behaviour of XmlDisassembler component. My problem was that I have developed a custom XmlDisassembler, that inside uses BizTalk XmlDisassembler component (Microsoft.BizTalk.Component.XmlDasmComp).

My component disassembles the message with the BizTalk component and discard some of the returned messages, based on some conditions. The problem is when I call XmlDasmComp's GetNext method, never ends.

Why? The problem is that in my conditions to discard the returned messages, I don't need to read the returned message. Inside the XmlDasmComp, in GetNext2 private method, it test a property 'IsNewDoc' to retrieve a new message or not. This property is updated only when we read the returned message.

Why this property is updated only when we read the returned message? Obvious, in BizTalk standard behaviour, it always read the returned message before to call GetNext method other time.

Standard behaviour in a BizTalk disassemble is:

1) XmlDasmComp.Disassemble
2) XmlDasmComp.GetNext (First Message)
3) Validate and ResolvePartyComponents (this components can read the message)
4) Receive Pipeline ends, then BizTalk READ THE MESSAGE
5) XmlDasmComp.GetNext (Second Message)
Until GetNext method returns a null message.

In my component, I was calling GetNext method continuosly without reading the message, so 'IsNewDoc' never was updated and GetNext method never ends.

Solution is, after calling GetNext method, I read the message and then I seek to the begin the message (If no, the internal Stream is in the last position and next components couldn't read it)

No comments: