With Artemis 2.0, with this JMS code...

         Queue jmsQ = sessionJMS.createQueue("nonExistingQueue");
         TextMessage m = sessionJMS.createTextMessage();
         m.setText("whatever");
         try (MessageProducer p = sessionJMS.createProducer(jmsQ);) {
            p.send(m);
         }

...an address/queue (with routingType= ANYCAST) is created on the server but AFAIK, based on the JMS specs, none of the methods called (createQueue(), createProducer(),send()) should do this !

The address/queue is "visible" when calling getAddress() on ResourceName.BROKER 
via the management API, even after the server is restart

Not sure what method exactly creates the address/queue but from the JMS specs, 
for the Session:createQueue() method it is said:

"...Note that this method simply creates an object that encapsulates the name of a queue. It does not create the physical queue in the JMS provider"

In fact, it seems that this the createProducer() method that creates the 
address/queue...

Also with this definition in broker.xml (From the documentation, chapter "Address  
Model"):
   <address name="address.foo">
      <anycast>
        <queue name="q1"/>
      </anycast>
   </address>

The following code

         Queue jmsQ = sessionJMS.createQueue("q1");
         TextMessage m = sessionJMS.createTextMessage();
         m.setText("whatever");
         try (MessageProducer p = sessionJMS.createProducer(jmsQ);) {
            p.send(m);
         }

fails on the createProducer() method with this exception:

ActiveMQQueueExistsException[errorType=QUEUE_EXISTS message=AMQ119019: Queue 
already exists q1]
    at 
org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:412)
    at 
org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:322)
    at 
org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext.createQueue(ActiveMQSessionContext.java:635)
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionImpl.internalCreateQueue(ClientSessionImpl.java:1836)
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionImpl.createQueue(ClientSessionImpl.java:389)
    at 
org.apache.activemq.artemis.jms.client.ActiveMQSession.createBrowser(ActiveMQSession.java:820)
    at 
org.apache.activemq.artemis.jms.client.ActiveMQSession.createBrowser(ActiveMQSession.java:782)

This may be related to the "auto-create-jms-queues" and "auto-create-jms-topics" settings, mut IMHO this seems to break JMS specs and in the second case it should not try to create tyhe address/queue it it already exists..


Reply via email to