我试图将消息发布到 activemq。但我在我的 java 应用程序中遇到了一个命名异常。这是下面的代码
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.setProperty(Context.PROVIDER_URL,"tcp://localhost:61616");
InitialContext ctx = new InitialContext(props);
// get the initial context
// InitialContext ctx = new InitialContext();
QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
// create a queue connection
QueueConnection queueConn = connFactory.createQueueConnection();
// lookup the queue object
Queue queue = (Queue) ctx.lookup("nixon");
我收到三个警告加上以下一个这样的错误
Exception in thread "main" javax.naming.NameNotFoundException: nixon
at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.youtube.rest2.status.ProducerNewClient.main(ProducerNewClient.java:38)
谁能告诉我为什么会收到此错误..?