With the ESB Guidance 2.0, I grabbed the Archive pipeline component in one of my projects. However, this component appears to be failing while archiving a flat file message in a send pipeline (Encode stage).
Error:
ForwardOnlyEventingReadStream does not support Seek()
This is original source code in the Archive component
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage message)
{
….
finally
{
if (binWriter != null)
{
binWriter.Flush();
binWriter.Close();
}
if (originalStrm != null)
originalStrm.Seek(0, SeekOrigin.Begin);
}
return message;
}
Solution:
In order to get away with the error, replace it with the following code:
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage message)
{
….
finally
{
if (binWriter != null)
{
binWriter.Flush();
binWriter.Close();
}
if (originalStream != null)
{
if (!originalStream.CanSeek)
{
ReadOnlySeekableStream seekableStream = new ReadOnlySeekableStream(originalStream);
seekableStream.Position = 0;
message.BodyPart.Data = seekableStream;
}
else
originalStream.Seek(0, SeekOrigin.Begin);
}
}
return message;
}
The ReadOnlySeekableStream is part of the Microsoft.BizTalk.Streaming assembly.
Happy saving ..err – archiving J
Two members of the Sydney BizTalk group (Michael Stephenson and Thiago Almeida) suggested to use Nick Heppleson archive component on codeplex. That is worth checking out as well.
Link: http://btsmsgarchcomp.codeplex.com/
Thanks guys..
Thank you.
I was having the same issue and this saved my time.
All good Naveen. I hope the ESB Guidance 2.0 resolves this error once it comes out of Beta (fingers crossed)