Having spring application (actually grails app) that runs apache-activemq server as spring bean and couple of apache-camel routes. Application use hibernate to work with database. The problem is simple. Activemq+Camel starts up BEFORE
grails injects special methods into hibernate domain objects (actually save/update methods etc). So, if activemq already has some data on startup - camel starts processing messages w/o having grails DAO methods injected. This fails with grails.lang.MissingMethodException
. Must delay activemq/camel startup before Grails injects special methods into domain objects.
views:
68answers:
3
A:
If all these are defined as spring bean, you can use
<bean id="activeMqBean depends-on="anotherBean" />
This will make sure anotherBean
is initialized before activeMqBean
Bozho
2010-08-11 19:02:35
Thanks Bonzo, but I know `depends-on` statement. Unfortunately it won't work as Grails initialization is on some different layer then Spring. So there's just no bean that activemq should depend on.
archer
2010-08-11 20:47:06
+3
A:
can you move MQ managment into a plugin? It would increase modularity and if you declare in plugin-descriptor
def loadAfter = ['hibernate']
you should have the desired behavior. Works for JBPM plugin
Sammyrulez
2010-08-12 08:27:12
Well, honestly I would NOT create/maintain separate plugin just to startup AMQ after hibernate is loaded. I'm assured that there's better way.
archer
2010-08-12 11:33:10
well in grails plugins are component. I have developed several plugin for apps just because I thought they would have been better modularized. Plugins are also a useful way to integrate legacy data or system. You maintain them as you maintain the app. You don't have to release them into the wild.
Sammyrulez
2010-08-13 07:20:00
I've got it ;) But in any case - I would NOT move single activemq.xml initialization file from main app into another `component` with complete grails plugin project structure, post it to svn and maintain another bunch of sources just to delay AMQ initialization.There's simpler way. AMQ bean support `start` property which indicates should it be autostarted or not. Will use it as for now.
archer
2010-08-14 06:43:36
A:
I am not sure in your case but lazy loading may also help e.g.
<bean id="lazybean" class="com.xxx.YourBean" lazy-init="true">
A lazily-initialized bean indicates to the IoC container to create bean instance when it is first requested. This can help you delay the loading of beans you want.
Gopi
2010-08-12 08:47:55
This won't work also, as my DAO bean is for sure requested BEFORE hibernate is loaded.
archer
2010-08-12 11:33:38