Serialization of a VirtualStream

Is it possible to serialize a VirtualStream for dehydration/rehydratation purposes? I have an aggregation helper class that is used to assemble a large message (from many small ones) over the duration of an orchestration. Right now I'm using a memorystream to store the aggregated messages, but I would like to buffer the content to disk since the large messages will grow in the future. I saw how I could store my aggregated messages using a filestream in this post (which is exactly what I need), but I would prefer to use the VirtualStream for performance reasons. Is there any way to create a class that inherits from VirtualStream and that could be serialized?

  • Edited by chgag Wednesday, April 22, 2015 11:24 PM
April 22nd, 2015 11:20pm

No, because any referenced or underlying type must also be serializable.

However, VirtualStream is already backed up by disk based the threshold you specify in the constructor so in most cases, the performance difference of FileStream and VirtualStream will be barely measurable.

Free Windows Admin Tool Kit Click here and download it now
April 23rd, 2015 7:45am

Thanks for your answers. As you said John, trying to serialize a virtualstream subclass was too complex, so I just wrote a serializable "kind of" virtualstream. It is pretty basic, it just builds up a message in a memorystream to a certain size and when it goes over that it switches to a filestream. Still testing it but so far it does what I expect during the lifetime of the orchestration (serialization during dehydratation/rehydratation). 

The reason why I wanted this is simple, we do aggregate some fairly large messages and, in this specific situation, I want to be able to buffer to disk, but the majority of the operations that we support daily are small messages that need to be processed as fast as possible. Right now, the small messages won't go to disk and will stay in the memorystream part of the class I wrote.

On to the next problem! (figuring out why sending a xlangmessage via a direct bound port does clone the xlangpart underlying stream three times in a row via ReplayableStreamStreamFactory!)

April 23rd, 2015 9:31pm

On to the next problem! (figuring out why sending a xlangmessage via a direct bound port does clone the xlangpart underlying stream three times in a row via ReplayableStreamStreamFactory!)

I hate to ask, but I'm curious, why are you even looking at that?
Free Windows Admin Tool Kit Click here and download it now
April 23rd, 2015 10:28pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics