I was using Spring.NET to create a message listener at application startup. I now need the ability to create 0-n listeners, some of which could be listening to different queues. I will need to be able to create/destroy them at run-time. What would be the best way to go about doing this? My previous spring configuration was something like:
<objects xmlns="http://www.springframework.net">
<object id='inputQueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
<property name='Path' value='.\Private$\inputQueue'/>
</object>
<!-- MSMQ Transaction Manager -->
<object id="messageQueueTransactionManager" type="Spring.Messaging.Core.MessageQueueTransactionManager, Spring.Messaging"/>
<!-- Message Listener Container that uses MSMQ transactional for receives -->
<object id="transactionalMessageListenerContainer" type="Spring.Messaging.Listener.TransactionalMessageListenerContainer, Spring.Messaging">
<property name="MessageQueueObjectName" value="inputQueue"/>
<property name="PlatformTransactionManager" ref="messageQueueTransactionManager"/>
<property name="MaxConcurrentListeners" value="10"/>
<property name="MessageListener" ref="messageListenerAdapter"/>
</object>
<!-- Adapter to call a PONO as a messaging callback -->
<object id="messageListenerAdapter" type="Spring.Messaging.Listener.MessageListenerAdapter, Spring.Messaging">
<property name="HandlerObject" ref="messageListener"/>
</object>
<!-- The PONO class that you write -->
<object id="messageListener" type="Com.MyCompany.Listener, Com.MyCompany">
<property name="Container" ref="transactionalMessageListenerContainer"/>
</object>
</objects>
Should I just programmatically do what this file is doing each time I need a new listener? Should I not use Spring.NET's messaging framework for this?