akka persist: After persist recovery fail, how can I do

27 views
Skip to first unread message

2817...@qq.com

unread,
May 31, 2016, 4:53:50 AM5/31/16
to Akka User List, 2817...@qq.com
In the book <<Akka Java Documentation, Release 2.3.10>> says that
"If there is a problem with recovering the state of the actor from the journal, the actor will be sent a RecoveryFailure message that it can choose to handle in receiveRecover. If the actor doesn’t handle the RecoveryFailure message it will be stopped"
But int the function onReceiveRecover,my code is following:
public void onReceiveRecover(Object msg) {
// TODO Auto-generated method stub
log.info("MyPersistentTest onReceiveRecover" );
State  st = this._currentState();
    log.info("my state: {}", st);
try {
if (msg instanceof myInfo) {
myInfo evt = (myInfo) msg;
log.info("get recover msg {}" ,evt); 
       } else if (msg instanceof SnapshotOffer)  {  
           System.out.println("After get snapshot msg " );           
       } else if (msg instanceof RecoveryFailure) {
        try {
        RecoveryFailure evt = (RecoveryFailure) msg;
        System.out.println(evt.cause());
        recoveryCompleted();
       
        //log.info("my state: {}", st);
        //super.preStart();
        } catch (InvalidClassException e) {
        log.info("InvalidClassException: {}", e);
        //e.printStackTrace();
        }
        //unhandled(msg);
       
       } 
       else if (msg instanceof RecoveryCompleted) {
        System.out.println("RecoveryCompleted" );
        //recoveryCompleted();
        //onRecoveryComplete();
        //st = this._currentState();
        //log.info("my state {}", st);
       }
       else {
        System.out.println("unhandled" );
        //unhandled(msg);
       }
} catch (Exception e) {
System.out.println("Exception" );
e.printStackTrace();
}
}

why my persist actor can not receive RecoveryCompleted msg.


Patrik Nordwall

unread,
May 31, 2016, 7:32:56 AM5/31/16
to akka...@googlegroups.com
If you are learning Akka you should use Akka 2.4. Rather much has changed in Persistence between 2.3 and 2.4

http://doc.akka.io/docs/akka/2.4.6/java/persistence.html

/Patrik

--
>>>>>>>>>> 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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages