Sending DocumentV2 instances to a REST endpoint

We need to send DocumentV2 instances obtained in e.g. an DocumentAfterUpdateEvent to a different REST endpoint (running outside of the DataServices server where the event occurred)

The kernel documentation isn’t clear whether DocumentV2 instances are serializable automatically or if I need to serialize and de-serialize them manually.

In the end I only need the difference between the two documents (as provided by DocumentV2Utils.compare()) so in the end the question is: is the DocumentChanges instance obtained from that serializable?

The service that implements the receiving controller class, will have kernel-md-facade included.

Edit: I need a solution that does not depend on the A12 models being present on the receiving side.

Hi @thomas-soft-grove,
since the interfaces related to DocumentV2 don’t implement Serializable, I would assume that they are not intended to be serialized automatically, as it is for IDocumentModel (just as comparison).
Speaking of DocumentChanges, I can think of using Jackson to (de)serialize the objects without the need of the corresponding DMs. If I would go for that, I would make sure that the deserialized Instant objects are correct in the second end point (I would expect that all other objects are deserialized correctly).
Just as a side note: There is the idea to provide serialization of documents without knowing the corresponding DM (see A12K-3289), but at the moment, it is just an idea.

Do you mean you can think of a future change to those classes, or do you think it might work already today (with 2025.06)?

We don’t really need the DM on the receiving side, as we are only interested in the field values. So if we can’t send DocumentChanges directly, we will use IDocumentV2Serializer to convert the document to JSON on the sender, then use pure Jackson on the receiver to extract and compare the field values.

I mean it might work already today with 2025.06, i.e. new ObjectMapper().writer().writeValueAsString(DocumentChanges) would produce the string on the sending side and new ObjectMapper().readValue(docChangesStr) would then parse the string on the receiving side.

At the moment, I cannot think of another alternative.

Thanks for the clarification.

Unfortunately serializing DocumentChanges fails with:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.mgmtp.a12.kernel.md.document.internal.service.implV2.immutable.ImmutableFieldInstanceV2Impl and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.mgmtp.a12.kernel.md.document.apiV2.documentchanges.internal.DocumentChangesImpl[“fieldChanges”]->java.util.ArrayList[0]->com.mgmtp.a12.kernel.md.document.apiV2.documentchanges.internal.ChangeImpl[“oldValue”])

Oh, I see. It is also good to know that it is not possible in that way, thanks for sharing.

Now, I have another idea (sorry that it took so long). You need the changes and DocumentChanges is not Serializable. Why don’t you extract the information, that you really need, from the DocumentChanges and create an own object which you can easily serialize on the sender side and deserialized on the receiving side.

Yes, that’s what we are going to do.