Akka Persistence Durable State

The durable state functionality was recently released in version 2.6.17. The release notes says it’s production ready. The documentation is still very light on this functionality. Are there full examples of configurations for durable state instead of code snippets? For example, I can’t find examples of how to setup the durable state plugin with the existing documentation. Also does durable state work with MySql and other DBs.

Hi Dan, I agree that the docs are missing some sample configurations, but except for that I think they cover all functionality there is, the API side of things in Akka: Persistence (Durable State) • Akka Documentation

The akka-persistence-jdbc is the only plugin I know of currently implementing the durable state store, the docs for that support is here: DurableStateStore • Akka Persistence JDBC as well as configuration and needed schemas in: Configuration • Akka Persistence JDBC

Is there something else in specific you are missing?

Hi Johan. I was referring to the documentation that you’ve provided when using this reference configuration mentioned in Configuration - Akka Persistence JDBC and specifying slick.jdbc.MySQLProfile$ with various MySQl related properties instead of Postgres. I was getting an error at startup Default DurableStateStore plugin is not configured, see 'reference.conf'

I’m assuming the error is related to this reference configuration . My confusion is the property is not specified in the reference.conf mentioned in the Configuration - Akka Persistence JDBC. Is there an example of this property?

I noticed that with the schemas listed in Configuration - Akka Persistence JDBC only H2 and Postgresql had the durable state tables defined, the rest of the DBs didn’t. So I’m curious if anybody else has tried MySQL. I can try Postgresql if that’s the recommended implementation.

Thanks for your response. Highly appreciate it.

I see, there are no docs yet for how to configure which store to use.

To set a default you set akka.persistence.state.plugin referencing a plugin implementation path, just like for the event journal plugin. For akka-persistence-jdbc that should be akka.persistence.state.plugin = jdbc-durable-state-store.
To set the store to use on a specific behavior/actor you use .withDurableStateStorePluginId(id) on DurableStateBehavior

Since Postgres is the one that has schema that should be a safe card, but I have a feeling that it could work with other database dialects as well, just that nobody created schema definition and tested them.

I created two issues to track improving the docs around this:

That resolved my issue. Thanks again Johan.

MySql is probably not ready yet due to this.

Indeed, Patrik just clarified that Postgres is the only one really supported for now, in the issue: Document which DB dialects support durable state store · Issue #612 · akka/akka-persistence-jdbc · GitHub

I got the write path working with Postgres. Thanks a bunch.

For the read path, the documentation was unclear about durable state projections.
I followed Source Provider Documentation to create the durable state source provider.
I was looking for documentation for durable state projection implementation but didn’t find any. Are we assuming to use JDBC projection?

The only specific for DurableState projections should be the source, handling the events and storing offsets should be possible to do in any way shown in the other parts of the projection documentation that fits your use case.

One important thing to note though is that the durable state updates are not guaranteed to be one per change like for an event sourced entity, since durable state updates in place, multiple subsequent updates to the same entity in a short time period can end up showing up as one update in the projection handler.