1

I am trying to figure out a way to use an AsynchronousSocketChannel along with a serialization technology.

My ultimate aim is to register a callback (specifying the target type) and it invoke my callback when a full-object has been de-serialized.

However, every serialization technology I've looked at relies on deserialisation in a blocking fashion.

Is there any serialization technology that will supports streaming deserialisation via proper use of AsynchronousSocketChannel (ie without converting it to a blocking InputStream first)

Alternatively, is there an efficient size delimited wrapper around AsynchronousSocketChannel that has been written that will give me a ByteArray, it seems silly to have to write this myself with the pools of ByteBuffers etc...

Cheetah
  • 13,785
  • 31
  • 106
  • 190
  • You'll probably have to do it yourself. IO that doesn't block needs to be polled periodically (in general, not just Java). You haven't mentioned anything about polling, so I'm not sure that non-blocking IO is going to work the way you expect. – markspace Apr 27 '16 at 18:52
  • Are you free to chose serialization format? If so, you can use Json or XML, for which asynchronous (de)serializers are known. – Alexei Kaigorodov Apr 27 '16 at 19:54
  • @AlexeiKaigorodov - I am free to choose a format...do you have any examples? – Cheetah Apr 27 '16 at 20:36
  • @AlexeiKaigorodov - I was hoping for one one that worked with POJOs – Cheetah Apr 27 '16 at 20:43
  • look at answers to http://stackoverflow.com/questions/6241159/incremental-streaming-json-library-for-java – Alexei Kaigorodov Apr 28 '16 at 03:02

0 Answers0