Search code examples
mongodbgrailsgrails-ormakka

Dynamic domain model properties not loading


Our project is a grails project which uses mongodb as its database. The domain models take advantage of the ability of mongo to have nested and dynamic fields. When using the dynamic finders in the project to retrieve a domain object it pulls back the dynamic fields fine.

We are now trying to implement AKKA to increase user response time by allowing some processes to run in the background apart from their initial request, instead of having them wait until the entire process finishes.

The current issue I am seeing is that when using the dynamic finders to retrieve the domain objects, it does not appear to be retrieving the dynamic fields. The message consists of three ObjectId elements and one service class which when the message is processed the service class is called with the ObjectId elements.

It returns the elements, but not their dynamic fields. Any insight into what I am missing would be appreciated.


Solution

  • Got it to work. It appears that the domain object being returned in the function call spawned from akka were not attached.

    We surrounded the call with DomainClass.withTransaction {} which appeared to fix the issue.

    However, we also changed the message to not have the service on the message and to look the service bean up in the application context before invocation.