I am using Akka projection with Akka persistence events as source. I don’t want to use eventsByTag because I don’t want to put the additional tagging step in my code. I can’t use eventsBySlice because this requires using R2dbc plugin in your event write, but I can’t touch the existing code which uses JDBC plugin. Also, I can’t use slices because I want the events for a persistence id to be consumed by the same projection.
Is there a a way to do akka events projection with JDBC and without tagging?
Akka Projection relies on the Akka Persistence Query API and there is no API to retrieve all the events at once. It’s either by persistenceId, by slice or by tag.
If you don’t want to add the tag and if you can’t switch to R2DBC plugin, I don’t see how you will be able to read the journal without building your own query implementation.
If you build your own query implementation you can integrate it with Akka Projection by implementing your own SourceProvider.
In your message you said:
Also, I can’t use slices because I want the events for a persistence ID to be consumed by the same projection.
There might be a misunderstanding here. Events from the same persistence ID are guaranteed to be added to the same slice and therefore consumed by the same projection. I understand that you can’t change the plugin impl, but I just want you to know how the slicing works. If it was not like that it would be quite useless.
Thank you for clearing my misunderstanding on slices. I’m taking there is something native to R2DBC that makes more sense to implement slices there? Now, that you cleared up slices, I wish I could use it with the JDBC plugin. Now, I have to find a way to distribute akka persistence event projections from JDBC plugin written source.
Thanks Andy I will consider this. For now I’ve fallen back to eventsByTag. This will not get previous events but in my case it is not important as long as I have a reference to a recent State. It so happens I do.
There is nothing native in R2DBC that allows slices. It’s just that we implemented this concept in the R2DBC and didn’t port it to the other plugins. That’s all.
Thanks. I’m going with eventsByTag and doing partitioning there. This will only be able to cover the new events but I think this is okay for our use case.