In ActiveMQ you do not have to create destinations up front before you can use them. The ActiveMQ broker auto-creates the physical resources associated with a destination on demand (i.e. when messages are sent to a new destination on a broker). This means that a client can create a new Queue or Topic dynamically either by
and the broker will automatically create the physical destinations for you. This avoids spending large amounts of time creating every individual destination you wish to use and possibly then exposing it in some JNDI provider. In addition, if you are using JNDI to lookup connection factory and destinations, you can specify which destinations you wish to create by default using the properties file. See the JNDI Support for more details. Creating destinations on startupIts completely optional but as of 4.1 you can Configure Startup Destinations to specify which destinations are automatically created when the broker starts. Limiting creation of destinationsIf you need to restrict access or creation of destinations then please use the Security option to disable destinations being auto-created for certain users. Client side destination objects are not the same as server side resources Note that the ActiveMQ Broker will only create server side resources for destinations when messages are actually sent to them. So you can create as many instances of ActiveMQTopic and ActiveMQQueue on a client without any real overhead until you actually send messages to them on a broker. So a JMS client creating a new ActiveMQQueue POJO does not mean you are creating server side queue resources. Think of the ActiveMQQueue and ActiveMQTopic classes as like java.net.URL. They are just names which refer to server side resources which are auto-created when they are used. You can browse the currently available queues and topics using JMX. You can also use the JMX MBeans to create the destinations you require. |