Search code examples
c#biztalkcustom-pipeline-componentbiztalk-pipelines

Producing two messages in BizTalk Send Port (From one input message)


I want to create two messages within a pipeline component and pass this onto the Assemble stage where it would go through the BTAHL7 Microsoft Accelerator.

The pipeline component would be placed in the Send Pipeline 'Pre-Assemble' stage.

This is the code which would return the messages.

private System.Collections.Queue qOutputMsgs = new System.Collections.Queue();
IBaseMessage[] allMessages = new IBaseMessage[] { pInMsg, pInMsg };

foreach (IBaseMessage msg in allMessages)
{
   qOutputMsgs.Enqueue(msg);
}

return (IBaseMessage)qOutputMsgs.Dequeue();

For testing purpose, I have added the two pInMsg into the an array, and looped through this array to add it to the queue. Then, returning the messages separated.

However, although the queue has 2 values, in the other parts of the pipeline (Assemble and Encode), it returns only one message.

Why does it do this? How can I get it to return two messages?


Solution

  • This logic won’t work in Execute method. You either need to implement IDisassembler interface for such pipeline and need to use it on a receive location. Or you use an orchestration to create multiple messages before sending to the send port.