I'm trying to upgrade from 0.6 to 0.7, and from what I saw the protocol itself is backward compatible.
We're having a lot of services out there which are using msgpack to communicate between them (RPC), and for doing this upgrade I must that the previous client (0.6) will know to deserialize 0.7 output, and vice-versa.
For now I'm having this two issues:
- Having the following code:
if (len < (1 << 5)) {
writeByte((byte) (FIXSTR_PREFIX | len));
}
else if (len < (1 << 8)) {
writeByteAndByte(STR8, (byte) len);
}
else if (len < (1 << 16)) {
writeByteAndShort(STR16, (short) len);
}
else {
writeByteAndInt(STR32, len);
}
STR8 is not something that the previous client knows how to handle, and the fix I did locally was just commenting out else if (len < (1 << 8)). This thing should be probably configurable, if you want to provide easier migration path.
- With the previous client, we serialized the values as Object array, that contained the fields the RPC needs to pass (may be primitives, String, Pojo's, and so on).
The way we did serializing with the previous client was:
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final Packer packer = msgPack.createPacker(outputStream);
final Object[] params;
if (requestParams == null) {
params = new Object[0];
} else {
params = requestParams;
}
packer.writeArrayBegin(params.length);
for (final Object param : params) {
packer.write(param);
}
packer.writeArrayEnd();
return outputStream.toByteArray();
now, with the new jackson databind I'm doing:
final ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
final Object[] params = new Object[]{ new MyPojo() }; // for example, may contain any other supported type / pojo
objectMapper.writeValueAsBytes(params);
and the byte array produced is not the same as the previous client, and it also contain all the fields of the pojo(?), which seems to miss one of the points of msgpack.
but if I'm also doing: objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);, the byte array not contains anymore all the field names, but still the produced byte array is not the same as with the previous client, which makes issues when trying to do de-serialize.
My questions are: is 0.7 should be backward compatible with 0.6 (in terms of consuming / producing same byte array)?
why does MessagePackFactory (of the databind package) produces also the field names in the byte array, and the feature of disabling it is not documented anywhere?
and last one is why does the produced output when serializing object array is different between 0.6 and 0.7 using the the specified API's?
Some relevant links:
our implementation with the previous client
serializing: https://github.com/outbrain/ob1k/blob/ob1k-0.152/ob1k-core/src/main/java/com/outbrain/ob1k/common/marshalling/MessagePackRequestMarshaller.java#L213
deserializing: https://github.com/outbrain/ob1k/blob/ob1k-0.152/ob1k-core/src/main/java/com/outbrain/ob1k/common/marshalling/MessagePackRequestMarshaller.java#L166
with the new client (0.7):
serializing: https://github.com/outbrain/ob1k/blob/msgpack_upgrade/ob1k-core/src/main/java/com/outbrain/ob1k/common/marshalling/MessagePackRequestMarshaller.java#L19
https://github.com/outbrain/ob1k/blob/msgpack_upgrade/ob1k-http/src/main/java/com/outbrain/ob1k/http/marshalling/JacksonMarshallingStrategy.java#L60
deserializing: https://github.com/outbrain/ob1k/blob/msgpack_upgrade/ob1k-core/src/main/java/com/outbrain/ob1k/common/marshalling/JacksonRequestMarshaller.java#L210
I'm trying to upgrade from 0.6 to 0.7, and from what I saw the protocol itself is backward compatible.
We're having a lot of services out there which are using msgpack to communicate between them (RPC), and for doing this upgrade I must that the previous client (0.6) will know to deserialize 0.7 output, and vice-versa.
For now I'm having this two issues:
STR8 is not something that the previous client knows how to handle, and the fix I did locally was just commenting out
else if (len < (1 << 8)). This thing should be probably configurable, if you want to provide easier migration path.The way we did serializing with the previous client was:
now, with the new jackson databind I'm doing:
and the byte array produced is not the same as the previous client, and it also contain all the fields of the pojo(?), which seems to miss one of the points of msgpack.
but if I'm also doing:
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);, the byte array not contains anymore all the field names, but still the produced byte array is not the same as with the previous client, which makes issues when trying to do de-serialize.My questions are: is 0.7 should be backward compatible with 0.6 (in terms of consuming / producing same byte array)?
why does MessagePackFactory (of the databind package) produces also the field names in the byte array, and the feature of disabling it is not documented anywhere?
and last one is why does the produced output when serializing object array is different between 0.6 and 0.7 using the the specified API's?
Some relevant links:
our implementation with the previous client
serializing: https://github.com/outbrain/ob1k/blob/ob1k-0.152/ob1k-core/src/main/java/com/outbrain/ob1k/common/marshalling/MessagePackRequestMarshaller.java#L213
deserializing: https://github.com/outbrain/ob1k/blob/ob1k-0.152/ob1k-core/src/main/java/com/outbrain/ob1k/common/marshalling/MessagePackRequestMarshaller.java#L166
with the new client (0.7):
serializing: https://github.com/outbrain/ob1k/blob/msgpack_upgrade/ob1k-core/src/main/java/com/outbrain/ob1k/common/marshalling/MessagePackRequestMarshaller.java#L19
https://github.com/outbrain/ob1k/blob/msgpack_upgrade/ob1k-http/src/main/java/com/outbrain/ob1k/http/marshalling/JacksonMarshallingStrategy.java#L60
deserializing: https://github.com/outbrain/ob1k/blob/msgpack_upgrade/ob1k-core/src/main/java/com/outbrain/ob1k/common/marshalling/JacksonRequestMarshaller.java#L210