Using DirectBuf

52 views
Skip to first unread message

Thomas Lo

unread,
Jul 30, 2013, 1:45:21 PM7/30/13
to the-blink...@googlegroups.com
I have created a very small class to test out the serialization and deserialization using jblink. Everything seems to work well except at the end of the data when no more data is available,  the program throws an exception thinking there is more data. Could you tell me if there is something I did wrong? I have attached the code basically after I serialize 2 data objects and I start deserializing it I got the following exception:

Unknown type id in blink message: 0

at com.pantor.blink.DefaultObjectModel.noBindingError(DefaultObjectModel.java:1070)

at com.pantor.blink.DefaultObjectModel.getGroupBinding(DefaultObjectModel.java:532)

at com.pantor.blink.CompactReaderCompiler.compile(CompactReaderCompiler.java:93)

at com.pantor.blink.CompactReaderCompiler.getDecoder(CompactReaderCompiler.java:64)

at com.pantor.blink.CompactReader.readMsg(CompactReader.java:722)

at com.pantor.blink.CompactReader.readOrSuspendMsg(CompactReader.java:699)

at com.pantor.blink.CompactReader.read(CompactReader.java:221)

at com.pantor.blink.CompactReader.read(CompactReader.java:176)

at com.flx.xs.common.data.serialization.blink.BlinkSerializer.main(BlinkSerializer.java:63)


Please let me know if there is a problem with my code. Thanks.

BlinkSerializer.java

david.rosenborg

unread,
Jul 31, 2013, 3:07:51 AM7/31/13
to the-blink...@googlegroups.com
It looks like your missing a call to the flip method between the writing and the reading of the messages. If you don't call flip it will start reading from the end of the buffer which happens to be filled with zeros in this case.

  buffer.flip();
  compactReader.read(buffer);

/D

Thomas Lo

unread,
Jul 31, 2013, 12:33:38 PM7/31/13
to the-blink...@googlegroups.com
David,

Thanks for the quick response.

1) Interesting where with the original program I was able to read the 2 data that were written to. It was just after reading the 2 data it will throw the exception
2) If I add the buffer.flip() before reading then I am no longer able to receive the 2 data that were written before. Then I played around with it a bit more and I got it working by eliminating the compactWriter.flush() and compactWriter.close(). Both these calls seem to prevent the reader to read from the buffer after the flip. Is that an expected behaviour?
Reply all
Reply to author
Forward
0 new messages