问题描述
我在第一次连接到慰藉时就变得异常了
javax.naming.exception:JNDI查找失败与路由器通信时出错。感谢你的帮助。
Hashtable
// assign Solace message router connection parameters
env.put(InitialContext.PROVIDER_URL,host);
env.put(Context.Security_PRINCIPAL,username + '@' + vpnName); // Formatted as user@message-vpn
env.put(Context.Security_CREDENTIALS,password);
// Create the initial context that will be used to lookup the JMS Administered Objects.
InitialContext initialContext = new InitialContext(env);
// Lookup the connection factory
ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);
// Create connection to the Solace router
Connection connection = connectionFactory.createConnection();
// Create a non-transacted,client ACK session.
Session session = connection.createSession(false,SupportedProperty.soL_CLIENT_ACKNowLEDGE);
System.out.printf("Connected to the Solace Message VPN '%s' with client username '%s'.%n",vpnName,username);
// Lookup the queue.
Queue queue = (Queue) initialContext.lookup(QUEUE_JNDI_NAME);
// From the session,create a consumer for the destination.
MessageConsumer messageConsumer = session.createConsumer(queue);
解决方法
这意味着您的应用程序无法访问Solace PubSub +代理。请确保纯文本SMF服务在代理端启动,并且应用程序主机可以通过端口55555与代理进行通信。