我正在编写一个应用程序来浏览JMS主题上的消息。下面是我获取初始上下文和初始化主题的代码:
public final static String JNDI_FACTORY="oracle.jms.AQjmsInitialContextFactory";
public final static String JMS_FACTORY="weblogic.jms.ConnectionFactory";
private void initTopic(Context context, String topicName) throws NamingException, JMSException {
System.out.println("initializing the queue...");
topicFactory = (TopicConnectionFactory) context.lookup(JMS_FACTORY);
topicConnection = topicFactory.createTopicConnection();
//queueConnection.setExceptionListener(this);
topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("session created, lookup queue: " + topicName);
topic = (Topic)context.lookup(topicName);
System.out.println("done...");
}
private InitialContext getInitialContext() throws NamingException
{
System.out.println("Opening connection to " + SERVER);
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
//env.put(Context.PROVIDER_URL, SERVER);
env.put(AQjmsContext.DB_URL, SERVER);
env.put(Context.SECURITY_PRINCIPAL, WLUSER);
env.put(Context.SECURITY_CREDENTIALS, WLPASSWORD);
return new InitialContext(env);
}
当我尝试跑步时,我收到错误:
javax.naming.NamingException: Cannot resolve name:weblogic.jms.ConnectionFactory [Root exception is javax.naming.NamingException: Unrecognized prefix in: weblogic.jms.ConnectionFactory]
编辑:非常确定我所要做的就是设置JMS_FACTORY="ConnectionFactory"