--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
Patrik Nordwall
Typesafe - Reactive apps on the JVM
Twitter: @patriknw
Hi Patrik,Sure and if that is how akka-persistence stays, that is what we will end up doing. But since persistence was marked as experimental, and it was stated that it will changed based on community feedback, I thought I would mention this feature that seems useful and powerful to me and hope others will think so as well.
The difference between having an actor that will then query a bunch of views and an actor that encapsulates all the the logic needed to get a true view of what the business needs to show is exactly that. Think of it as a viewmodel, like you would have in an MVVM app. But, as you pointed out, just like many things in development, there are workarounds.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
Hi Patrik,
That would be perfect for the needs I was thinking of. I hope that makes it in to a future version.
Hi Patrick,
In a situation with a lot of (Eventsourced)Processors and having a View to store certain (view) state into a database (or other storage), You need to take care of the way connections to these storage are managed, especially when it is used together with cluster sharding.
A single view that is able to proces the events per node (or for multiple nodes) allows for an easy construction of a CQRS style view model and allows me to use that same actor to ask for the view data. (this is how it's done with the Axon framework)
Let's assume that I need this functionality, in what way would you change the persistence code to support this ?
It seems that my other option is to create a distributed publish subscribe mechanism using channels in order to aggregate the data, but I prefer to construct it in a way that's inline with the way persistence works / will work.
Kind regards,
Olger
On Tuesday, April 15, 2014 9:44:51 PM UTC+2, delasoul wrote:Hello,
problems using a view for multiple processors have been discussed before, e.g.:It would still be a great feature to have though(when you need an aggregated view on events of multiple processors).The solution to send the events from views to an aggregator still leaves me with the question why then use a view at all and not just send the events fromthe processor to the aggregator directly? When using a view in the "middle" one has to deal again with not sending duplicate messages to the aggregator when viewsreplay, persistence(if needed) of the aggregator, losing messages etc. or am I missing smthg?
michael
On Monday, 14 April 2014 16:42:08 UTC+2, Chanan Braunstein wrote:
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
-- Martin Krasser blog: http://krasserm.blogspot.com code: http://github.com/krasserm twitter: http://twitter.com/mrt1nz
I'm currently working on view composition using the brand new akka-stream module. Basic idea is to make views stream producers and to use the akka-stream DSL to merge message/event streams from several producers into whatever you need. See also https://twitter.com/mrt1nz/status/457120534111981569 for a first running example.
WDYT?
Hi Martin,
I'm currently working on view composition using the brand new akka-stream module. Basic idea is to make views stream producers and to use the akka-stream DSL to merge message/event streams from several producers into whatever you need. See also https://twitter.com/mrt1nz/status/457120534111981569 for a first running example.
WDYT?
First of all Nice stuff !, I think this is useful for the system at my hands (real-time patient monitoring based on medical data)I've seen the streams announcements but did not dive into that yet. Looking at your code StreamExample.scala it more or less 'clicks' in concept. (and hopefully in the right way)
From a 'View' perspective as currently is available in akka-persistence, every producing actor needs a view attached to it in order to push the events to the streams producer, right ? (when I look at the ViewProducer.scala code, this is what is done.)
PersistentFlow.fromProcessor("p1").toProducer(materializer)
Now, I have a sharding cluster with an EventsourcedProcessor (expect 10.000ths of these EventsourcedProcessor actor instances) , so I'll need to create a line like this for every EventsourcedProcessor in order to get the stream of events together. Thereafter, I need to merge them together to get a single stream of events. (at least that is one of the features of using the streams)
My goal is to have 'Listeners' (that is my interpretation of a 'View' due to historic reasons...) that will for instance update a data store, this will probably happen on on just a few nodes (maybe 1 and some failover stuff). These 'Listeners' need to attach to the sharded Eventsourced system and ask to get all event sourced events forwarded. (publish subscribe more or less).
I wonder if the current View (or ViewProducer) fits this situation due to the fact you need to create as many views as eventsourcedprocessors are created.With the merged streams thereafter, it seems a possibility to have just one thing per node (I assume actor) that will do the writing to a data store (not being the eventstore).What would be the way to get these Views 'automagically' attached to the proper procesors ?
And, do you have a pointer how this issue is solved with it's own eventstore ? In a sharding cluster, you more or less have the same issue. (would streams change your approach there ?)
Hi Olger,
installing 10k views/producers won't scale, at least not with the current implementation. Here are some alternatives:
- Maybe a custom journal plugin is what you need: a plugin that delegates all write/read requests to the actual journal actor and that additionally updates a database with the events to be written. This essentially installs a single "listener" per ActorSystem (this is to some extend comparable to a database trigger that executes additonal commands. If the backend datastore supports that directly, I recommend implementing the trigger there, if possible).
- Instead of having thousands of processors, what speaks against combining them into a single processor (or only a few) per node?
Further comments inline ...
On 18.04.14 16:10, Olger Warnier wrote:
Hi Martin,
I'm currently working on view composition using the brand new akka-stream module. Basic idea is to make views stream producers and to use the akka-stream DSL to merge message/event streams from several producers into whatever you need. See also https://twitter.com/mrt1nz/status/457120534111981569 for a first running example.
WDYT?
First of all Nice stuff !, I think this is useful for the system at my hands (real-time patient monitoring based on medical data)I've seen the streams announcements but did not dive into that yet. Looking at your code StreamExample.scala it more or less 'clicks' in concept. (and hopefully in the right way)
From a 'View' perspective as currently is available in akka-persistence, every producing actor needs a view attached to it in order to push the events to the streams producer, right ? (when I look at the ViewProducer.scala code, this is what is done.)
PersistentFlow.fromProcessor("p1").toProducer(materializer)
Now, I have a sharding cluster with an EventsourcedProcessor (expect 10.000ths of these EventsourcedProcessor actor instances) , so I'll need to create a line like this for every EventsourcedProcessor in order to get the stream of events together. Thereafter, I need to merge them together to get a single stream of events. (at least that is one of the features of using the streams)
Every processor instance itself could create such a producer during start and send it to another actor that merges received producers.
My goal is to have 'Listeners' (that is my interpretation of a 'View' due to historic reasons...) that will for instance update a data store, this will probably happen on on just a few nodes (maybe 1 and some failover stuff). These 'Listeners' need to attach to the sharded Eventsourced system and ask to get all event sourced events forwarded. (publish subscribe more or less).
I wonder if the current View (or ViewProducer) fits this situation due to the fact you need to create as many views as eventsourcedprocessors are created.With the merged streams thereafter, it seems a possibility to have just one thing per node (I assume actor) that will do the writing to a data store (not being the eventstore).What would be the way to get these Views 'automagically' attached to the proper procesors ?
See above.
And, do you have a pointer how this issue is solved with it's own eventstore ? In a sharding cluster, you more or less have the same issue. (would streams change your approach there ?)
There's one journal actor per ActorSystem where n journal actors in a cluster update a replicated journal.
Hope that helps.
Cheers,
Martin
--
Hi Patrick,Sounds like an interesting approach, storing some meta-data at the view may help to check / show the reliability of the system.At this moment the events are sent to a processor per node that publishes the event (distributed pub sub)
When you talk about view, that's the akka-persistence view ?
So more or less, the sub processors could send messages to the View and when there is a Persist() around it, it will be stored.
On Sun, Apr 20, 2014 at 2:47 PM, Olger Warnier <ol...@spectare.nl> wrote:
Hi Patrick,Sounds like an interesting approach, storing some meta-data at the view may help to check / show the reliability of the system.At this moment the events are sent to a processor per node that publishes the event (distributed pub sub)That sounds good, as well.When you talk about view, that's the akka-persistence view ?Yes, persistence.View and persistence.ProcessorSo more or less, the sub processors could send messages to the View and when there is a Persist() around it, it will be stored.I'm not sure I understand what you mean here. Let me clarify my proposal with an example. Let's say we have a User aggregate root with some profile information that can be updated. The user is represented by a User EventsourcedProcessor actor, which is sharded. On the query side we want to be able to search users by first and last name, i.e. we want to store all users in a relational database table on the query side.
The User actor persist FirstNameChanged, and inside the persist block it sends a Persistent(FirstNameChanged) message to the AllUsers Processor. On the query side we have a AllUsersView connected to that processor. When AllUsersView receives FirstNameChanged it updates the db table.
To handle lost messages between User and AllUsers you might want to send an acknowledgement from AllUsers to User, and have a retry mechanism in User. I would implement that myself in User, but PersistentChannel might be an alternative.
That is the most straight forward solution. The drawback is that FirstNameChanged is stored twice. Therefore I suggested the meta-data alternative. User sends Persistent(UserChangedNotification(processorId))) to the AllUsers Processor. When AllUsersView receives UserChangedNotification it creates a child actor, a View for the processorId in the UserChangedNotification, if it doesn't already have such a child. That view would replay all events of the User and can update the database table. It must keep track of how far it has replayed/stored in db, i.e. seqNr must be stored in the db. The child View can be stopped when it becomes inactive.
That alternative is more complicated, and I'm not sure it is worth it.
On Sunday, April 20, 2014 4:59:22 PM UTC+2, Patrik Nordwall wrote:On Sun, Apr 20, 2014 at 2:47 PM, Olger Warnier <ol...@spectare.nl> wrote:
Hi Patrick,Sounds like an interesting approach, storing some meta-data at the view may help to check / show the reliability of the system.At this moment the events are sent to a processor per node that publishes the event (distributed pub sub)That sounds good, as well.When you talk about view, that's the akka-persistence view ?Yes, persistence.View and persistence.ProcessorSo more or less, the sub processors could send messages to the View and when there is a Persist() around it, it will be stored.I'm not sure I understand what you mean here. Let me clarify my proposal with an example. Let's say we have a User aggregate root with some profile information that can be updated. The user is represented by a User EventsourcedProcessor actor, which is sharded. On the query side we want to be able to search users by first and last name, i.e. we want to store all users in a relational database table on the query side.Yup, great sample.The User actor persist FirstNameChanged, and inside the persist block it sends a Persistent(FirstNameChanged) message to the AllUsers Processor. On the query side we have a AllUsersView connected to that processor. When AllUsersView receives FirstNameChanged it updates the db table.Indeed. In what way is the AllUsersView connected to that Processor ? (in a distributed pub sub situation)
(although, I have to understand in what way 'inside the persist block' is to be interpreted.
To handle lost messages between User and AllUsers you might want to send an acknowledgement from AllUsers to User, and have a retry mechanism in User. I would implement that myself in User, but PersistentChannel might be an alternative.Is it possible todo persistent channels with the distributed pub sub stuff that's available in akka ?
That is the most straight forward solution. The drawback is that FirstNameChanged is stored twice. Therefore I suggested the meta-data alternative. User sends Persistent(UserChangedNotification(processorId))) to the AllUsers Processor. When AllUsersView receives UserChangedNotification it creates a child actor, a View for the processorId in the UserChangedNotification, if it doesn't already have such a child. That view would replay all events of the User and can update the database table. It must keep track of how far it has replayed/stored in db, i.e. seqNr must be stored in the db. The child View can be stopped when it becomes inactive.Will that work with a sharded cluster ? (and a 'View' may be running on another node)
That alternative is more complicated, and I'm not sure it is worth it.From a solution perspective, using the distributed pub sub, maybe with persistent channels is what will do.Most of my questions have todo with using akka-persistence as a full fledged DDD framework, not too hard without the sharding (although a view for every aggregate root instance seems not to fit when you want to use that for database connectivity that contains a view model). with the sharding it is more complicated and a good structure to actually build a view that is on 'some' node listening for events, doing' it's thing is a handy part.
On Sun, Apr 20, 2014 at 6:05 PM, Olger Warnier <ol...@spectare.nl> wrote:On Sunday, April 20, 2014 4:59:22 PM UTC+2, Patrik Nordwall wrote:On Sun, Apr 20, 2014 at 2:47 PM, Olger Warnier <ol...@spectare.nl> wrote:
Hi Patrick,Sounds like an interesting approach, storing some meta-data at the view may help to check / show the reliability of the system.At this moment the events are sent to a processor per node that publishes the event (distributed pub sub)That sounds good, as well.When you talk about view, that's the akka-persistence view ?Yes, persistence.View and persistence.ProcessorSo more or less, the sub processors could send messages to the View and when there is a Persist() around it, it will be stored.I'm not sure I understand what you mean here. Let me clarify my proposal with an example. Let's say we have a User aggregate root with some profile information that can be updated. The user is represented by a User EventsourcedProcessor actor, which is sharded. On the query side we want to be able to search users by first and last name, i.e. we want to store all users in a relational database table on the query side.Yup, great sample.The User actor persist FirstNameChanged, and inside the persist block it sends a Persistent(FirstNameChanged) message to the AllUsers Processor. On the query side we have a AllUsersView connected to that processor. When AllUsersView receives FirstNameChanged it updates the db table.Indeed. In what way is the AllUsersView connected to that Processor ? (in a distributed pub sub situation)In a persistent View you define the processorId that it will read the persistent messages from. It reads (replays) from the journal periodically, or when you send it a Update message. You can have many views connected to the same processor. The processor doesn't have to know anything about the views. In a distributed setup you will use a distributed/replicated journal and thereby the view can be located on another machine than the processor.
(although, I have to understand in what way 'inside the persist block' is to be interpreted.Ah, I thought you were familiar with EventsourcedProcessor. Read up on it in the docs:
To handle lost messages between User and AllUsers you might want to send an acknowledgement from AllUsers to User, and have a retry mechanism in User. I would implement that myself in User, but PersistentChannel might be an alternative.Is it possible todo persistent channels with the distributed pub sub stuff that's available in akka ?Yes, PersistentChannel requires a confirmation from the destination, so if you wrap/forward the ConfirmablePersistent and send it via pub-sub it should be fine. It will not work if you publish to multiple subscribers.
That is the most straight forward solution. The drawback is that FirstNameChanged is stored twice. Therefore I suggested the meta-data alternative. User sends Persistent(UserChangedNotification(processorId))) to the AllUsers Processor. When AllUsersView receives UserChangedNotification it creates a child actor, a View for the processorId in the UserChangedNotification, if it doesn't already have such a child. That view would replay all events of the User and can update the database table. It must keep track of how far it has replayed/stored in db, i.e. seqNr must be stored in the db. The child View can be stopped when it becomes inactive.Will that work with a sharded cluster ? (and a 'View' may be running on another node)yesThat alternative is more complicated, and I'm not sure it is worth it.From a solution perspective, using the distributed pub sub, maybe with persistent channels is what will do.Most of my questions have todo with using akka-persistence as a full fledged DDD framework, not too hard without the sharding (although a view for every aggregate root instance seems not to fit when you want to use that for database connectivity that contains a view model). with the sharding it is more complicated and a good structure to actually build a view that is on 'some' node listening for events, doing' it's thing is a handy part.Thanks for your thoughts. I'm sure patterns and tools around this will evolve from the experience of using akka persistence in real applications.
(I've read the akka-dev thread on reliable messaging and the use of a MQ kind of thing for that, but I prefer to keep it clustered without a specific additional component in between)
That is the most straight forward solution. The drawback is that FirstNameChanged is stored twice. Therefore I suggested the meta-data alternative. User sends Persistent(UserChangedNotification(processorId))) to the AllUsers Processor. When AllUsersView receives UserChangedNotification it creates a child actor, a View for the processorId in the UserChangedNotification, if it doesn't already have such a child. That view would replay all events of the User and can update the database table. It must keep track of how far it has replayed/stored in db, i.e. seqNr must be stored in the db. The child View can be stopped when it becomes inactive.Will that work with a sharded cluster ? (and a 'View' may be running on another node)yesThat alternative is more complicated, and I'm not sure it is worth it.From a solution perspective, using the distributed pub sub, maybe with persistent channels is what will do.Most of my questions have todo with using akka-persistence as a full fledged DDD framework, not too hard without the sharding (although a view for every aggregate root instance seems not to fit when you want to use that for database connectivity that contains a view model). with the sharding it is more complicated and a good structure to actually build a view that is on 'some' node listening for events, doing' it's thing is a handy part.Thanks for your thoughts. I'm sure patterns and tools around this will evolve from the experience of using akka persistence in real applications.Cheers,Olger
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
Based on all your remarks, I found the way to get this organised using the Views for scanning changes and thereafter starting an actor with the specific actorpath of the sharded eventsourced instance in order to process all changes (the meta-data option as you called it). As said, that solves the issues of storing data twice and keeps the whole application reasonably simple (no application level acknowledgements back and forth)Thanks for your support, really helped me to get this nailed. (A raw version of this is working on my machine now)
The User actor persist FirstNameChanged, and inside the persist block it sends a Persistent(FirstNameChanged) message to the AllUsers Processor. On the query side we have a AllUsersView connected to that processor. When AllUsersView receives FirstNameChanged it updates the db table.To handle lost messages between User and AllUsers you might want to send an acknowledgement from AllUsers to User, and have a retry mechanism in User. I would implement that myself in User, but PersistentChannel might be an alternative.That is the most straight forward solution. The drawback is that FirstNameChanged is stored twice.
On Sun, Apr 20, 2014 at 2:47 PM, Olger Warnier <ol...@spectare.nl> wrote:
Hi Patrick,Sounds like an interesting approach, storing some meta-data at the view may help to check / show the reliability of the system.At this moment the events are sent to a processor per node that publishes the event (distributed pub sub)That sounds good, as well.When you talk about view, that's the akka-persistence view ?Yes, persistence.View and persistence.ProcessorSo more or less, the sub processors could send messages to the View and when there is a Persist() around it, it will be stored.I'm not sure I understand what you mean here. Let me clarify my proposal with an example. Let's say we have a User aggregate root with some profile information that can be updated. The user is represented by a User EventsourcedProcessor actor, which is sharded. On the query side we want to be able to search users by first and last name, i.e. we want to store all users in a relational database table on the query side.The User actor persist FirstNameChanged, and inside the persist block it sends a Persistent(FirstNameChanged) message to the AllUsers Processor. On the query side we have a AllUsersView connected to that processor. When AllUsersView receives FirstNameChanged it updates the db table.To handle lost messages between User and AllUsers you might want to send an acknowledgement from AllUsers to User, and have a retry mechanism in User. I would implement that myself in User, but PersistentChannel might be an alternative.
Hi Patrick,
Le dimanche 20 avril 2014 16:59:22 UTC+2, Patrik Nordwall a écrit :On Sun, Apr 20, 2014 at 2:47 PM, Olger Warnier <ol...@spectare.nl> wrote:
Hi Patrick,Sounds like an interesting approach, storing some meta-data at the view may help to check / show the reliability of the system.At this moment the events are sent to a processor per node that publishes the event (distributed pub sub)That sounds good, as well.When you talk about view, that's the akka-persistence view ?Yes, persistence.View and persistence.ProcessorSo more or less, the sub processors could send messages to the View and when there is a Persist() around it, it will be stored.I'm not sure I understand what you mean here. Let me clarify my proposal with an example. Let's say we have a User aggregate root with some profile information that can be updated. The user is represented by a User EventsourcedProcessor actor, which is sharded. On the query side we want to be able to search users by first and last name, i.e. we want to store all users in a relational database table on the query side.The User actor persist FirstNameChanged, and inside the persist block it sends a Persistent(FirstNameChanged) message to the AllUsers Processor. On the query side we have a AllUsersView connected to that processor. When AllUsersView receives FirstNameChanged it updates the db table.To handle lost messages between User and AllUsers you might want to send an acknowledgement from AllUsers to User, and have a retry mechanism in User. I would implement that myself in User, but PersistentChannel might be an alternative.Let's say the current version in production only have User actors.Now we want to deliver an new version that include the new Query with the AllUsers Processor.How can we be sure that AllUsers receive all the events to be able to construct its state?
Let's say we have a User aggregate root with some profile information that can be updated. The user is represented by a User EventsourcedProcessor actor, which is sharded. On the query side we want to be able to search users by first and last name, i.e. we want to store all users in a relational database table on the query side.
The User actor persist FirstNameChanged, and inside the persist block it sends a Persistent(FirstNameChanged) message to the AllUsers Processor. On the query side we have a AllUsersView connected to that processor. When AllUsersView receives FirstNameChanged it updates the db table.
To handle lost messages between User and AllUsers you might want to send an acknowledgement from AllUsers to User, and have a retry mechanism in User. I would implement that myself in User, but PersistentChannel might be an alternative.
It must keep track of how far it has replayed/stored in db, i.e. seqNr must be stored in the db.