Announcement Announcement Module
Collapse
No announcement yet.
Runtime creation of new DefaultMessageListenerContainer for new queue/destination Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Runtime creation of new DefaultMessageListenerContainer for new queue/destination

    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.

  • #2
    Hi,
    Any luck with this?
    I am dealing with the same issue now.

    thanks.

    Comment


    • #3
      I (newbie) am also looking to solve same issue. Someone, please help! Thanks.

      Comment


      • #4
        Originally posted by ona View Post
        I (newbie) am also looking to solve same issue. Someone, please help! Thanks.
        You need to configure them as prototype beans and activate the DMLC, but you cannot destroy them as prototype beans are controlled by Container.

        I tried these options to create multiple DMLC's for on Demand topics, but I was unable to destroy them

        Below link has more info on DMLC

        http://stackoverflow.com/questions/1...ands-of-topics

        I had successfully built a framework without DMLC to create topics on demand and destroy them on demand and automatic re-subscription of topics onException

        Right now I am working on JMS connection polling using spring. Once I have the pool of connections then I can use random function to distribute my topics across the pool.

        Comment

        Working...
        X