store icon indicating copy to clipboard operation
store copied to clipboard

Get objects that will be peristed

Open hg-ms opened this issue 2 years ago • 3 comments

thanks @hg-ms do you think it might be of interest for you guys to incorporate some sort of a listener API for this inside the code? I am thinking about potential use cases like outbox pattern, Change Data Capture integration etc... this would be beneficial I think...

Originally posted by @guykatz in https://github.com/eclipse-store/store/discussions/134#discussioncomment-8404941

hg-ms avatar Feb 08 '24 14:02 hg-ms

There is a way to get all objects that will be persisted, but it is a bit hacky: To do so you need to create a storer and cast it to BinaryStorer.Default. Between the store and commit you can retrieve all objects that will be persisted.

BinaryStorer.Default storer = (Default) storage.createLazyStorer();
storer.store(root);
storer.iterateMergeableEntries((oid, instance) -> {System.out.println("oid: " + oid + " instance: " + instance);} );
storer.commit();

This is not very user friendly, mybe we can add a more convenient API

hg-ms avatar Feb 08 '24 14:02 hg-ms

vote + 1, the feature could be a good alternative for mongodb change stream.

hu-chia avatar Feb 22 '24 10:02 hu-chia

Maybe we should consider adding a concept like the Hibernate interceptors.

fh-ms avatar Apr 17 '24 07:04 fh-ms

added method void registerObjectCollector(PersistenceObjectCollector collector) to the storers that allows to add custom collector implementations.

hg-ms avatar Dec 05 '24 14:12 hg-ms