One of my projects we were working on the the Archiving pipeline component. we want to file in any stage of the pipeline component, hence we had it as any type
[ComponentCategory(CategoryTypes.CATID_Any)]
[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]
Error faced:
There was a failure executing the send pipeline: “<Pipeline assembly>” Source: “<Pipeline Component name>” Send Port: “<Send port name>” URI: “URI path” Reason: ForwardOnlyEventingReadStream does not support Seek()
Cause:
usage of stream (System.IO.Stream) object when it is non seekable. when the stream object becomes non seekable the data in the stream get lost. when tried to retreive data from the stream the above error appears.
Solution:
Use seekable object from the class Microsoft.BizTalk.Streaming.ReadOnlySeekableStream. This ReadOnlySeekableStream is overrided implemenation (Inherited class) ofthe stream and handles seekable stream.
//Donot use stream objects
originalStrm = new ReadOnlySeekableStream(inmsg.BodyPart.GetOriginalDataStream());
//After Catch use this
finally
{
if (binWriter != null)
{
binWriter.Flush();
binWriter.Close();
}
if (originalStrm != null)
{
if (!originalStrm.CanSeek)
{
ReadOnlySeekableStream seekableStream = new ReadOnlySeekableStream(inmsg.BodyPart.GetOriginalDataStream());
seekableStream.Position = 0;
inmsg.BodyPart.Data = seekableStream;
inmsg.BodyPart.Data.Position = 0;
}
else
{
originalStrm.Seek(0, SeekOrigin.Begin);
inmsg.BodyPart.Data = originalStrm;
}
}
}