Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventAdapter has no effect on receiveRecover (fromJournal method is not called) #173

Closed
wenhuancui opened this issue Oct 9, 2017 · 5 comments
Labels

Comments

@wenhuancui
Copy link

wenhuancui commented Oct 9, 2017

As the title says, events stored as BSONDocument cannot be 'automatically' converted back (pattern matching on event type is failing). And log shows that fromJournal method is not called. However, toJournal method of the EventAdapter is definitely called, as confirmed in the corresponding mongodb collection.
Version info is as follows:

com.github.scullxbones
akka-persistence-mongo-rxmongo_2.12
2.0.3

@scullxbones
Copy link
Owner

Hi @wenhuancui

The event adapter is outside of the control of persistence plugins such as this one, it's used entirely by the akka-persistence layer. I'm confused as to what you're reporting as far as an issue for this plugin to address.

What may be the problem is that the event-adapter-bindings need to be specified in both directions. In other words, there should be a mention of BSONDocument, linking it to your EventAdapter implementation, in addition to whatever scala class you're using to model your events (or sealed trait). Without any code, it's hard to say for sure.

I'd say you could refer to #165 - but there's not much to go on there, other than EventAdapter has worked for others. I also have it working at my day job as part of a continuous test suite.

@wenhuancui
Copy link
Author

Thanks @scullxbones. I had read the link #165, and yes it has little information, so I stumbled on this matter. Your clarifications are great for a newbie like me, especially this one: "The event adapter is outside of the control of persistence plugins...there should be a mention of BSONDocument" .
So I changed the configuration and it worked like a charm:
akka-contrib-mongodb-persistence-journal {
event-adapters{
luckyEventAdded =
"com.learnscala.explore.akka.persistence.lottery.LuckyEventAdapter"
}
event-adapter-bindings{
"com.learnscala.explore.akka.persistence.lottery.LuckyEvent"=luckyEventAdded
"reactivemongo.bson.BSONDocument"=luckyEventAdded
}
}

The key is the last line. Thanks again.
P.S. Maybe adding such clarifications to the docs can keep other newbies from this mistake?

@scullxbones
Copy link
Owner

That's great news - happy to help out 👍

@scullxbones
Copy link
Owner

Added #174 to track the docs change.

@asarkar
Copy link

asarkar commented Dec 11, 2017

+1 @wenhuancui. #165 is a contender for the worst GitHub issue for the year ("Got it working, sorry." - really, wtf?), your description helped me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants