5.2. 配置远程 JNDI

远程 JNDI 客户端可以根据名称从 JNDI 连接和查找对象。若要使用远程 JNDI 客户端查找对象,它必须在其类路径 中包含 jboss-client.jarjboss-client.jar 位于 EAP_HOME/bin/client/jboss-client.jar

以下示例演示了如何在远程 JNDI 客户端中从 JNDI 查找 myTestQueue 队列:

示例: MDB 资源适配器的配置

Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
properties.put(Context.PROVIDER_URL, "remote+http://HOST_NAME:8080");
context = new InitialContext(properties);
Queue myTestQueue = (Queue) context.lookup("jms/queue/myTestQueue");