The spring documentation says:
Destinations, as ConnectionFactory instances, are JMS administered objects that you can store and retrieved in JNDI. When configuring a Spring application context, you can use the JNDI JndiObjectFactoryBean factory class or to perform dependency injection on your object’s references to JMS destinations.
However, this strategy is often cumbersome if there are a large number of destinations in the application or if there are advanced destination management features unique to the JMS provider.
The question is:
How to proceed when I have a large number of destinations in my application?
Using the strategy mentioned above I have to define:
- JndiTemplate
- JndiDestinationResolver
- JndiObjectFactoryBean
- CachingConnectionFactory
- JmsTemplate
For EACH destination.
So If I have 20 queues, I'll have to define 100 such beans...
JmsTemplate
andConnectionFactory
(assuming they all are using the same JMS provider/instance). Everything else can be lazily looked up using thesend(destination, message)
methods on theJmsTemplate
. – M. Deinum