Hi Filippo,

thanks a lot for your insights. This was very helpful. 

Cheers 


On Monday, May 9, 2016 at 5:46:50 PM UTC+2, Filippo De Luca wrote:
>
> Hi Peter,
> Assuming the actor has a status represented by a case class MyActorStatus. 
> You need a way to write this status out and be able to reload.
>
> The akka-persistence uses the akka-serialization mechanism. It is an 
> extension of Akka that you can use like this:
>
> private[this] var myStatus: MyActorStatus = _
>
> val serialization = SerializationExtension(actorSystem)
>
> def preStart(){
>   super.preStart()
>   myStatus = (for {
>     bytes <- readStatus()
>     status <- serialization.deserialize(bytes, classOf[MyActorStatus]
>   } yield status).getOrElse(throw new Exception("Error recovering status"))
> }
>
> def postStop() {
>
>   // I would save the satus async once in while as the backend could be   
>     //unavailable sometime.
>   for {
>     bytes <- serialization.serialize(myStatus)
>     ok <- writeStatus(bytes)
>   } yield ok
>
>   super.postStop()
> }
>
> You can use this or another serialization depending on your persistence 
> backend. It is a Sql DB you can use slick instead. If you are going to use 
> something like s3 instead I think the akka serialization fit your needs.
>
> cheers
>
>
> On 9 May 2016 at 13:53, 'Peter' via Akka User List <
> [email protected] <javascript:>> wrote:
>
>> Hi Filippo, 
>>
>> thanks for your answer. As also Patrick stated out, it seems to be the 
>> better way to not go with akka persistence. But what I don't see, is an 
>> very easy way with Serialisation. Can you probably give me a bit more about 
>> what you have in mind? 
>> In general, I need to make a snapshot of the actors state if this 
>> changes. If the actor dies, this state needs to be recovered. 
>>
>> Thanks, Peter
>>
>> On Monday, May 9, 2016 at 1:27:30 PM UTC+2, Filippo De Luca wrote:
>>>
>>> In my opinion you don't need akka-persistence at all. You just want to 
>>> save the current actor state. It could be done very easily without 
>>> akka-persistence using the Serialisation to serialize the status.
>>>
>>> On 9 May 2016 at 10:31, 'Peter Schrott' via Akka User List <
>>> [email protected]> wrote:
>>>
>>>> Dear Pros,
>>>>
>>>> From my Akka application it makes more sense to only use the snapshots. 
>>>> I don't want to use the journal at all.
>>>>
>>>> Do you see any problems with doing that which I might not have 
>>>> considered?
>>>>
>>>> My second problem with that is, that I wanted to delete old snapshots. 
>>>> I.e. keep only the current one. The deletion should take place on the 
>>>> SaveSnapshotSuccess. Initially I did not expect that the sequence 
>>>> number is only updated at a journal logs. This of course makes sense after 
>>>> thinking about it. But my problem remains, I can not identify my latest 
>>>> snapshot as the sequence number stays at 0. I will always delete all 
>>>> snapshots. 
>>>>
>>>> Thanks for helping, Peter
>>>>
>>>> -- 
>>>> >>>>>>>>>> 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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at https://groups.google.com/group/akka-user.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>>  
>>>
>>> [image: --]
>>> Filippo De Luca
>>> [image: http://]about.me/FilippoDeLuca
>>> <http://about.me/FilippoDeLuca?promo=email_sig>  
>>>  
>>>
>> -- 
>> >>>>>>>>>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>  
>
> [image: --]
> Filippo De Luca
> [image: http://]about.me/FilippoDeLuca
> <http://about.me/FilippoDeLuca?promo=email_sig>  
>  
>

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to