Search code examples
mongodbhibernatejpareactivelagom

Is it possible to Use MongoDB for Lagom persistence?


The Lagom Documentation does not mention anything about MongoDB support, but Lagom seems to have JPA and JDBC support.

Can Hibernate OGM be used as a JPA interface between MongoDB & Lagom?

ReactiveMongo driver is one good candidate which even works with Playframework. Any possibility to use it with Lagom?

Is there any other way of achieve the same?


Solution

  • Lagom doesn't offer integration with MongoDB out of the box, so you'd have to roll you own.

    There are two distinct parts to integrating a persistence solution in Lagom, depending on what you want. If you want to store Lagom's persistence event journal and snapshots in MongoDB, you'd need a Akka Persistence plugin and some glue code to integrate that with Lagom. There seems to be a plugin for MongoDB available, and integrating that shouldn't be too hard. You should study an existing implementation (like lagom-persistence-cassandra or lagom-persistence-jdbc) for inspiration.

    If you're fine with storing the journal and snapshots in a supported store (Cassandra or JDBC), but needs to access MongoDB as part of your read-side, things are easier. Lagom offers generic read side support, and you're free to implement your processors however you want. The documentation page on persistence read-side should have enough information to get you started.