Hi All,
Please note, this is my first thread so may be you can guide me if anything is wrong here.
Also I have tried searching for solution in this/other forums but could not find it. If you have any links, please share.
--
I am trying to develop an application where I can add new destinations and listeners to them at runtime to my web applications. No. of destination-listener pairs are unknown and can change during lifetime of the application. I need to add/remove them dynamically keeping web application running and also not calling context.refresh().
For this I am using DefaultMessageListenerContainer which will forward any new message to already available messageListener bean.
Also I have used BeanDefinitionRegistryPostProcessor which gives me control to add new bean definitions after loading of bean xml but before actual initialization of the beans.
So at deploy time, I can create as many destination-listener pairs as required. But this only works at the deployment time of the application.
Also I have an ApplicationContextProvider which implements ApplicationContextAware which I can use to access application context.
Now I need to add functionality where user provides a new destination and I need to initialize a new listener for it in same web application.
--
I have tried
1) Creating a new instance of DefaultMessageListenerContainer and then setting destination, messageListener,
connectionFactory. But here I need to do:
defaultMessageListenerContainer.initialize();
defaultMessageListenerContainer.start();
and
applicationContext.getBeanFactory().registerSingle ton(beanName, defaultMessageListenerContainer);
after which the listener initializes but it still cannot get access to other bean objects (e.g. BO/DAO) called during processing of received message.
Seems like I am not able to wire the other beans in this object.
2) When I use
applicationContext.getBeanFactory().createBean(Def aultMessageListenerContainer.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);
spring bean initialization fails saying it requires destination property...
When I pass 'false' for dependencyCheck argument, it again fails saying it requires connection factory.
--
What I really want is a single listener listening to multiple destinations (where I could add/remove the destinations at runtime) but spring listeners do not listen on multiple destinations (correct?). So I am trying to initialize new listener, for new destination and that too, during lifetime of the application.
Any idea how to do this?
Any other way/approach to implement the same functionality will also do.
Thanks.


Reply With Quote
