0

I need to find a generic way to publish event on every action like saving, updating, deleting data in database, regardless of database used (can be Google Cloud Platform Datastore or any other repository). For now we are using aspects, but we found it slippery to use it for such a business logic like publishing events to e.g. Pubsub. I found a solution in Spring Data REST Core and @RepositoryEventHandler, but I cannot make it work with Spring Data Cloud Datastore repository, it is just not triggered. I tried it with REST calls, not unit tests; also used proper HTTP methods, but still does not work. Are there any funky, fancy solution to achieve my goal? Or maybe I just misunderstood the concept of RepositoryEventHandler annotation?

PS. I found one question regarding RepositoryEventHandler, but this still does not work for me. This is the topic.

Nibrass H
  • 2,403
  • 1
  • 8
  • 14
Morales
  • 128
  • 2
  • 11
  • I found the following post that may come in useful for your use case. The only downside is that they are not using Java. However, I think it would be worth checking it out. Link is [here](https://stackoverflow.com/questions/53512171/create-update-in-datastore-triggers-cloud-function). They are listening on events from Cloud Datastore, such as create, delete, or update, to trigger a Cloud Function. Let me know if this helps you at all. – sllopis Jan 20 '20 at 14:21

1 Answers1

0

You can use RepositoryRestResource and publish the message to pub/sub for Auditing each event.

Vikram Shinde
  • 1,022
  • 6
  • 17