Currently we are using the A12 DocumentService directly injected in the Spring context in CRON Jobs and Kafka-Consumers i.e. without using the A12 JavaClient or implementing a custom operation that is executed per JSON-RPC request. We have noticed that this produced a memory leak in our application, since the DocumentService publishes create/update events that lead to the creation of a rollback-cache that is never cleared. We found a way to temporarily fix this issue by manually clearing the cache, essentially rebuilding parts of the A12 internal handling of JSON-RPC requests, but this entails importing internal A12 packages. Question: What is the recommended solution here?
Hi @tobias-gentle-alder, what and how exactly do you call? I can not help you based on this description. It’s too generic, not explaining which events do you mean, which method do you call from which code, what causes the memory leatk and so on.
Simply calling com.mgmtp.a12.dataservices.document.DocumentService#create or #update publishes events that reference created/updated documents, that are chached by the internal A12 RollbackPostProcessor. This cache is then cleared by JsonRpcOperationDispatcher but only in the context of an RPC request. If DocumentService#create/#update#create are called outside such a context, cache is never cleared, resulting in a memory leak.
The Backend Tutorials in the A12 documentation make use of the DocumentService only to retrieve documents. At the moment, I am not clear about what the intended usage of the DocumentService would be, outside a custom RPC operation
Using service is the correct way. But this approach shouldn’t add anything to the RPC context. So, please create a bug ticket if this happens.