James Mann's Blog

The blog of James Mann

Creating Multiple Messages in a BizTalk Server disassemble pipeline component

There is a interface IBaseMessageFactory that you can use to create instances of BizTalk messages and BizTalk message parts.

You can grab a handle to an instance of a subtype of this interface from within the Dissassemble method using the IPipelineContext.GetMessageFactory().

An important thing to note is that in order to preserve the message context you must grab this from the original message and poke it into the new instances created by the factory. The following code illustrates it.

public void Disassemble(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
IBaseMessageContext sourceContext = inmsg.Context;
IBaseMessagePart part = inmsg.BodyPart;

// queue four messages to be processed in the GetNext() method.
// _msgs is a simple Queue
_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
_msgs.Enqueue(CreateMessage(pc, sourceContext,part));

private string messageType = @"http://www.myschema.com/schemas/myschemamessage/MySchema";
private string systemPropertiesNamespace = @"http://schemas.microsoft.com/BizTalk/2003/system-properties";

public IBaseMessage CreateMessage(IPipelineContext pc, IBaseMessageContext sourceContext, IBaseMessagePart part)
IBaseMessage msg = pc.GetMessageFactory().CreateMessage();
msg.AddPart("Body", part, true);

// comment out the following line to preserve the original message
msg.BodyPart.Data = new MemoryStream(ASCIIEncoding.ASCII.GetBytes("blah blah blah"));
msg.Context = sourceContext;
msg.Context.Promote("MessageType", systemPropertiesNamespace, messageType);
return msg;

Comments (26) -

  • Steve

    11/30/2007 9:35:23 PM |

    I have a question. I am doing something similar, but something weird happens. The messages are built in the Disassemble method. I add them to a queue just the same, then inside of GetNext the code looks like this:

    if (_msgs.Count > 0)

     return (IBaseMessage)qOutputMsgs.Dequeue();


     return null;

    Sometimes it works, and the pipeline returns me the messages I built, but other times it does not; it goes into GetNext tries to return the first message and then it stops, and the message never gets retrieved from the receive location nor put in the message box. Have you any suggestion as to what could be the problem.


  • Reviews on Hypothyroidism Revolution

    10/30/2013 9:55:33 PM |

    I was recommended this web site by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my trouble. You are wonderful! Thanks!

    Also visit my web-site;  Reviews on Hypothyroidism Revolution - http://hypothyroidismrevolutionreview.tumblr.com

  • Arab Voyeur

    11/9/2013 2:35:16 PM |

    We are a gaggle of volunteers and opening a brand new scheme in our community. Your web site provided us with valuable info to work on. You've performed a formidable job and our entire group will be grateful to you.

    My homepage;  Arab Voyeur - http://imc.ichiayi.com/userinfo.php?uid=38329

  • Blondes Grannies

    11/22/2013 6:04:19 PM |

    Nice post. I learn something totally new and challenging on sites I stumbleupon everyday. It will always be helpful to read through articles from other writers and use a little something from other websites.

    Visit my web page  Blondes Grannies - http://nxnn.info/user/SilviaFul

  • Water Softener Installation

    1/3/2014 1:43:48 PM |

    Hello, I enjoy reading all of your article post. I wanted to write a little comment to support you.|

  • Restaurant Equipment

    1/5/2014 2:11:51 PM |

    Hey there! I simply want to offer you a big thumbs up for your excellent information you have here on this post. I am returning to your website for more soon.|

  • Denny Bungard

    1/20/2014 6:24:51 PM |

    obama is cool

  • Denny Bungard

    1/20/2014 7:00:35 PM |

    thanks for posting the link to vip xxx

  • Sanford Murguia

    6/4/2014 5:16:07 PM |

    this is a sample comment

  • moja kawa

    6/28/2014 3:14:08 PM |

    Great ˇV I should certainly pronounce, impressed with your website. I had no trouble navigating through all the tabs and related info ended up being truly simple to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or something, web site theme . a tones way for your customer to communicate. Nice task..

  • On sport news

    7/2/2014 4:34:07 PM |

    Of course yourself can.

  • On Sport information

    7/2/2014 4:56:19 PM |

    Hello, i ought to say excellent web oneself contain, i stumbled throughout it in just Bing. Does oneself buy substantially visitors?

  • Sport information

    7/2/2014 4:59:01 PM |

    Good day would by yourself head sharing which website system by yourself're doing work with? I'm shifting in direction of get started my private weblog before long however I'm taking in a difficult period analyzing among BlogEngine/Wordpress/B2evolution and Drupal. The explanation I question is given that your structure and design and style seems to be choice then maximum weblogs and I'm seeking for anything extensively exclusive.  P.S Sorry for currently being off-matter still I experienced in direction of request!

  • On sport news

    7/2/2014 7:04:57 PM |

    Hey - great world-wide-web, basically hunting close to some weblogs, seems to be a very great system your self are getting. I'm previously taking Wordpress for a couple of my web-sites nonetheless on the lookout in direction of difference just one of them above in direction of a system related in the direction of yours as a demo work. One thing within just unique yourself would propose concerning it?

  • Gregory Despain

    8/7/2014 12:52:29 AM |

    Wonderful writing! I think you have really touched on some valid points and I agree with you on many aspects. It?s been a great pleasure.

  • DEBORA Laurence

    8/11/2014 10:36:23 PM |

    ELIHES,Transport de voyageur & vtc elihes.com/, Chauffeur privé sur paris et région parisienne.

  • DEBORA Laurence

    8/15/2014 4:45:12 PM |

    annuaires-gratuit.com/ vous propose de créer gratuitement un annuaire de sites internet pour un bon référencement.

  • DEBORA Laurence

    8/15/2014 4:58:52 PM |

    annuaires-gratuit.com/ vous propose de créer gratuitement un annuaire de sites internet pour un bon référencement.

  • Lynwood Kopas

    8/18/2014 11:40:33 AM |

    is nolvadex the same as tamoxifen <a href="wholebodyvibration.net/ForumRetrieve.aspx;>tamoxifen bupropion</a> tamoxifen induced gene expression tamoxifen absorption test?

  • DEBORA Laurence

    8/24/2014 2:26:55 PM |

    annuaires-gratuit.com/ vous propose de créer gratuitement un annuaire de sites internet pour un bon référencement.

  • DEBORA Laurence

    8/25/2014 6:15:23 AM |

    annuaires-gratuit.com/ vous propose de créer gratuitement un annuaire de sites internet pour un bon référencement.

  • idlife

    12/8/2014 6:40:48 PM |

    Nice post! Check out my site sometime!

  • Cash

    12/13/2014 4:29:31 AM |

    Nice post! I enjoyed reading your post, I have a blog too. Hopefully you can keep your site updated so I can keep reading.

  • Mental Health Social Network

    12/15/2014 2:38:16 PM |

    Hello, nice post!

  • Екозид

    12/18/2014 7:52:29 PM |

    I am delighted to see that you are putting so much of effort for encouraging the visitors with valuable blogposts about tablets, similar to this, I have sent this posting to my Digg account.

  • levitra 20mg

    12/22/2014 6:35:27 PM |

    I like what you guys are up also. Such smart work and reporting! Carry on the excellent works guys I've incorporated you guys to my blogroll. I think it'll improve the value of my website Smile.

  • qlek search engine

    1/13/2015 1:35:17 PM |

    There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game. Both boys and girls feel the impact of just a moment’s pleasure, for the rest of their lives.

  • seo links

    1/13/2015 9:29:13 PM |

    I was very pleased to find this web-site.I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.

  • fruit slots

    1/18/2015 9:57:47 PM |


  • porno

    1/19/2015 9:22:37 PM |


  • Silas Marinez

    1/21/2015 9:07:19 PM |

    This is the right blog for anyone who wants to find out about this topic. You realize so much its almost hard to argue with you (not that I actually would want…HaHa). You definitely put a new spin on a topic thats been written about for years. Great stuff, just great!

  • Irena Foth

    1/25/2015 2:09:15 PM |

    Whats up! I simply wish to give an enormous thumbs up for the great information you've gotten here on this post. I will be coming again to your blog for extra soon.

  • dying light video

    2/16/2015 7:28:44 PM |

    I am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more.

  • seo links

    4/5/2015 3:14:37 PM |

    There is noticeably a bundle to know about this. I assume you made certain nice points in features also.