On saving a domain object in a service, with a flush: true
on the save of the domain, the object isn't getting saved before I have to use the object.
Domain domain = new Domain(property: something.toString()).save(failOnError: true, flush: true)
I'm unsure how to force a flush of the hibernate session in either of the services that I'm using.
For some context, I'm making an API call to an API service, which goes to another service where I'm saving the domain, then back to the API service then adding a string to a RabbitMQ queue then returning a 200OK to the user. But because the domain isn't getting saved in the second service, when the item is added to the queue, rabbitMQ is handling the message before the domain is saved.
EDIT:
My current fix:
API controller:
def apiActionCreate()
{
Map returnMap = apiService.createAction(params, request)
rabbitSend staticQueue, [id: returnMap.id.toString()]
}
API service:
Map createAction(GrailsParameterMap params, HttpServletRequest request)
{
//do some logic related to a related domain
seperateService.someAction(domain.id)
}
Service where I'm saving domain:
Map someAction(UUID id)
{
Domain domain = new Domain(property: something.toString()).save(failOnError: true, flush: true)
}