Monday, April 27, 2009

Today I was working with a pipeline component which encrypted fields in an XML message, for sensitive information. I realized that I needed to use it with a Flat File disassembler, which means that the original message was not XML, so I had to put my component after the Flat File disassembler. For various reasons, I wanted to use my component no later than the Dissasembler stage for this scenario.

So first, I added IDisassemblerComponent to the list of interfaces being implemented in my pipeline component class.

Then, I added the following code:

private bool beginMessage = false;
private IPipelineContext pContext;
private IBaseMessage pInMsg;

void IDisassemblerComponent.Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
beginMessage = true;
this.pContext = pContext;
this.pInMsg = pInMsg;

IBaseMessage IDisassemblerComponent.GetNext(IPipelineContext pContext)
if (beginMessage)
beginMessage = false;
return Execute(pContext, pInMsg);
return null;

This will only work if the previous disassembler is supposed to produce one message.

4/29/2010 - Changed the code to reflect changes suggested by Johan Rex...


Johan Rex said...

You may not want to assign the beginMessage variable to false just before you evaluate on it. As it's written th if clause will always evaluate to false and no message will be produced. Not even the first time that I suspect was your intention.

Steve Harclerode said...

I think you're right...I don't have the original code any more, but I actually did get it working. I guess I posted the wrong version.