In my Cuba application I have a rabbitMQ Listener which listens to a rabbitMQ queue. When picking up a message from the queue, I convert that message to an object using the injected Metadata interface, with the method metadata.getClass(“project$Order”), and then I serialize it.
All works fine, but when I deploy a new version, on starting up, the first few messages it picks up from the queue fail due a NullPointerException.That’s because the Metadata interface doesn’t have it’s session yet, so it fails on the above method.
What would be the proper way of handling this ?
 I’ve found these in the logfiles. The second line is my attempt to get the session, which normally throws the exception:
- 12:58:35.402 INFO com.haulmont.cuba.core.sys.MetadataImpl - Initializing metadata
- Failed attempt # 1 getting metadata.getSession()
- 12:58:35.675 INFO com.haulmont.cuba.core.sys.MetadataImpl - Metadata initialized in 273ms