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 (8) -

  • 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();


    else


     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.


    Thanks

  • 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?

Loading