Search code examples
activemq-classicjndi

ActiveMQ Dynamic Queues have dynamicQueues in their name


I am using dynamic queues for testing with names like dynamicQueues/Foo, but in the web console I am seeing the queue names as dynamicQueues/Foo rather than just Foo.

Other code (not ours) uses the same dynamicQueues/Foo but the queue name on the console is just Foo so things are misaligned so to speak.

I have followed the instructions here: http://activemq.apache.org/jndi-support.html

I am confused about whether the queue name reported in the web console should include dynamicQueues or not - finding it hard to debug our problem as a result.


Solution

  • You should see Foo in the console window, yes.

    This code will produce a message on FOO and show the queue as FOO in the web console (amq 5.6.0):

    Properties props = new Properties();
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
    props.setProperty(Context.PROVIDER_URL,"tcp://127.0.0.1:61616");
    javax.naming.Context ctx = new InitialContext(props);
    ConnectionFactory cf = (ConnectionFactory)ctx.lookup("ConnectionFactory");
    Connection conn = cf.createConnection();
    Destination dest = (Destination)ctx.lookup("dynamicQueues/FOO");
    Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer prod = s.createProducer(dest);
    prod.send(s.createTextMessage("Hello, World!"));
    

    Are you sure you are using JNDI to lookup the queue and that you did not configure anything in jndi.properties?