JBoss return org.JBoss.remoting.ProtocolException:打开的通道太多
我的程序遇到错误: “org.jboss.remoting3.ProtocolException:打开的频道太多” 我从互联网上搜索了一些解决方案来修复这个错误。不幸的是,其他人的建议对我不起作用 下面是关于如何调用jndi远程和我使用的属性的代码JBoss return org.JBoss.remoting.ProtocolException:打开的通道太多,jboss,connection,jndi,remote-access,channels,Jboss,Connection,Jndi,Remote Access,Channels,我的程序遇到错误: “org.jboss.remoting3.ProtocolException:打开的频道太多” 我从互联网上搜索了一些解决方案来修复这个错误。不幸的是,其他人的建议对我不起作用 下面是关于如何调用jndi远程和我使用的属性的代码 public static void createUser(String loginID) throws Exception { Hashtable props = new Hashtable(); try { pr
public static void createUser(String loginID) throws Exception {
Hashtable props = new Hashtable();
try {
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, "remote://" + localhost:4447);
props.put("jboss.naming.client.ejb.context", "true");
props.put(Context.SECURITY_PRINCIPAL, "userJBoss");
props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
context = new InitialContext(props);
context.lookup("ejb:/createUserOperation/CreateUserGenerator!password.api.CreateUserService");
.....
......
LOGGER.info("DONE");
} catch (Exception e) {
LOGGER.error("ERROR");
} finally {
context.close();
}
}
由于某些原因,我无法显示该方法的所有内容
每次需要创建新用户时,都会调用“createUser”。它将被调用上百或上千次
每次执行完方法后,我都会关闭连接
假设我已经调用该方法100次,一些用户将成功创建,而一些用户将失败
以下错误将提示我:
2014-12-04 17:23:23,026 - ERROR [Remoting "config-based-naming-client-endpoint" task-4] (org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver- Line:134) - Failed to open channel for context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@bbaebd6, receiver=Remoting connection EJB receiver [connection=Remoting connection <78e43506>,channel=jboss.ejb,nodename=webdev01]} org.jboss.remoting3.ProtocolException: Too many channels open
2014-12-04 17:23:23026-错误[Remoting“基于配置的命名客户端端点”任务4](org.jboss.ejb.client.Remoting.RemotingConnectionEJBReceiver-第134行)-无法打开上下文EJBReceiverContext{clientContext=org.jboss.ejb.client的通道。EJBClientContext@bbaebd6,receiver=远程连接EJB接收器[connection=Remoting连接,channel=jboss.ejb,nodename=webdev01]}org.jboss.remoting3.ProtocolException:打开的通道太多
一旦发生错误,我就需要重新启动jboss,有时还会出现错误
如果有人能帮助解决我面临的问题,我将不胜感激
谢谢您使用的是混合上下文属性 这应该足够了
final Properties ejbProperties = new Properties();
ejbProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
ejbProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
ejbProperties.put("remote.connections", "1");
ejbProperties.put("remote.connection.1.host", "localhost");
ejbProperties.put("remote.connection.1.port", "4447");
ejbProperties.put("remote.connection.1.username", "ejbuser");
ejbProperties.put("remote.connection.1.password", "ejbuser123!");
final EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(ejbProperties);
final ConfigBasedEJBClientContextSelector selector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(selector);
final Context context = new InitialContext(ejbProperties);
// lookup
Foo proxy = context.lookup("ejb:/createUserOperation/CreateUserGenerator!password.api.CreateUserService");
使用org.jboss.ejb.client.naming
时,它会创建EJBClientContext
对象
关闭context
时,您正在关闭InitialContext
而不是EJBClientContext
要关闭EJBClientContext
EJBClientContext.getCurrent().close();
存在一个错误(EAP 6,AS 7),即打开和关闭过多实例过快会导致以下错误:
错误:无法打开上下文EJBReceiverContext的通道
而不是:
最终属性=。。。
最终上下文=新的初始上下文(属性);
请尝试缓存一组属性的上下文:
private Map initialContexts=new HashMap();
最终上下文=getInitialContext(属性);
私有InitialContext getInitialContext(最终属性)引发异常{
final Integer hash=properties.hashCode();
InitialContext结果=initialContexts.get(哈希);
如果(结果==null){
结果=新的初始上下文(属性);
initialContexts.put(散列,结果);
}
返回结果;
}
记住调用close()
当不再需要上下文时。根据jboss的版本,您可以在远程连接器的配置中增加值,例如
请参见:,你好,费德里科,谢谢您的建议。我使用的是jboss 7.1.1,以前在standalone.xml中没有设置任何MAX_OUTBOUND_消息。您知道defa是什么吗ult MAX_OUTBOUND_MESSAGES?看起来默认值是从[RemotingOptions.java]()