Using the pass-through pipeline - String versus XmlDocument
As part of a larger solution, I had what I thought would be a quick orchestration to build: take text files from a folder and combine them into a single text file. There are a lot of examples of the aggregation pattern using BizTalk out there, and I used the sequential convoy pattern.
I set up a receive port and location to receive the individual text files. I set up a filter expression on my initial receive shape to receive only messages that came in through that receive port. In my orchestration, I created a message of type string to receive the individual text files.
When I deployed, the receive port picked up the text files and immediately suspended, because no subscribers were found. I examined the subscription of the orchestration, and wouldn't you know, it required the MessageType to be set to string. The problem is that with the pass-through pipeline, no MessageType is set. I had a few options.
In the orchestration, because my message was an XmlDocument and not a string, I could no longer append the string values of my messages. I created a method in a helper class that would convert my message back into its true string form:
I set up a receive port and location to receive the individual text files. I set up a filter expression on my initial receive shape to receive only messages that came in through that receive port. In my orchestration, I created a message of type string to receive the individual text files.
When I deployed, the receive port picked up the text files and immediately suspended, because no subscribers were found. I examined the subscription of the orchestration, and wouldn't you know, it required the MessageType to be set to string. The problem is that with the pass-through pipeline, no MessageType is set. I had a few options.
- Create a flat file schema, a receive pipeline with a flat file disassembler, and a send pipeline with a flat file assembler. Seemed like overkill when I really didn't care about the contents of the files.
- Create a custom pipeline component that simply created and promoted a MessageType property of string. That would also have required receive and send pipelines that contained the customer pipeline component.
- In the orchestration, change the message type from string to XmlDocument. The interesting thing about this is BizTalk does its subscriptions differently for these two cases.
In the orchestration, because my message was an XmlDocument and not a string, I could no longer append the string values of my messages. I created a method in a helper class that would convert my message back into its true string form:
Some of the other options are discussed in more detail at http://support.microsoft.com/kb/837860
public string GetString(XLANGMessage msg)
{
StreamReader reader = new StreamReader((Stream)msg[0].RetrieveAs(typeof(Stream)));
string retval = reader.ReadToEnd();
return retval;
}
Labels: biztalk
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home