我已经通过在activemq.xml(ActiveMQ版本5.2.0)中配置它,如documentation中所述设置队列。ActiveMQ:问题与队列查找
<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);
我receveing下面的错误,虽然队列中JConsole的可见( Tree/org.apache.activemq/Queue):
javax.naming.NameNotFoundException: DUMMY
请告诉我我做错了什么。非常感谢!
感谢您解释创建主题/队列并将其映射到JNDI上下文之间存在差异。我怀疑我们试图解决的队列/主题连接问题的根源在于创建== JNDI注册的假设。 – 2009-11-17 21:11:45