如文档中所述,我通过在 activemq.xml(ActiveMQ 版本 5.2.0)中配置它来设置队列。
<destinations>
<queue physicalName="FOO.BAR" />
<queue physicalName="DUMMY" />
</destinations>
我正在尝试使用以下代码从java(在同一主机上)访问它:
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
properties.put(Context.PROVIDER_URL, "tcp://localhost:61616");
context = new InitialContext(properties);
factory = (ConnectionFactory) context.lookup("ConnectionFactory");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
queueName = "DUMMY"; // which can be either FOO.BAR or DUMMY
dest = (Destination) context.lookup(queueName);
我收到以下错误,尽管队列在 jconsole(树/org.apache.activemq/队列)中可见:
javax.naming.NameNotFoundException: DUMMY
请告诉我我做错了什么。非常感谢!