Jakarta ee JBoss AS 7中群集EJB不平衡

Jakarta ee JBoss AS 7中群集EJB不平衡,jakarta-ee,ejb,cluster-computing,jboss7.x,load-balancing,Jakarta Ee,Ejb,Cluster Computing,Jboss7.x,Load Balancing,我已经成功地将2个JBoss集群设置为7个实例,并部署了以下SLSB: @Stateless @Remote(TestEJBRemote.class) @Clustered public class TestEJB implements TestEJBRemote { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(...);

我已经成功地将2个JBoss集群设置为7个实例,并部署了以下SLSB:

@Stateless
@Remote(TestEJBRemote.class)
@Clustered
public class TestEJB implements TestEJBRemote {
  private static final long serialVersionUID = 1L;
  private static final Logger logger = Logger.getLogger(...);

  @Override
  public void test() {
    String nodeName = System.getProperty("jboss.node.name");
    logger.info(nodeName);
  }
}
从日志文件中,我可以看到bean已正确部署在集群上。在客户端,我创建了许多线程,用于查找和调用
TestEJB
的实例。但是,似乎所有实例都在同一个节点中结束

以下是“jndi.properties”文件:

和“jboss ejb client.properties”:

在客户端中,我执行
final InitialContext ctx=new InitialContext()然后在每个线程内形成:

String name = "ejb:/test//TestEJB!" + TestEJBRemote.class.getName();
TestEJBRemote remote = (TestEJBRemote) ctx.lookup(name);
remote.test();
我做错了什么

更新

如果仅指定连接列表中的第二个节点,则会得到:

java.lang.IllegalStateException:没有EJB接收器可用于处理调用上下文的[…]组合org.jboss.EJB.client.EJBClientInvoc
关联上下文

所以可能这个问题需要先解决

更新2

通过在从属节点中设置应用程序用户,我最终解决了这个问题。以前,我试图以管理用户的身份进行连接,但没有成功


只要我在连接列表(在“jboss ejb client.properties”中)中指定一个从节点,负载平衡现在也可以工作。如果我指定主节点,那么所有EJB将只在该节点中结束。但是,这个解决方案对我来说已经足够了。

看起来您需要在属性建筑中指定两个服务器。另外,JBoss 7.1中似乎有一个but,因此您至少应该使用7.2,以下示例取自:

Properties properties = new Properties();
properties.put("endpoint.name", "farecompare-client-endpoint");
properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
properties.put("remote.connections", "cmc5101,cmc5102");
properties.put("remote.connection.cmc5101.host", "cmc5-101");
properties.put("remote.connection.cmc5101.port", "4447");
properties.put("remote.connection.cmc5101.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
properties.put("remote.connection.cmc5102.host", "cmc5-102");
properties.put("remote.connection.cmc5102.port", "4447");
properties.put("remote.connection.cmc5102.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
PropertiesBasedEJBClientConfiguration configuration = new PropertiesBasedEJBClientConfiguration(properties);
final ContextSelector ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(configuration);
final ContextSelector previousSelector = EJBClientContext.setSelector(ejbClientContextSelector);
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
也可能有帮助。
另一个

谢谢你的回复。我正在使用最新的7.2.0.Alpha(也尝试了7.1.3.Final)。即使有两个连接,所有调用都会在同一个节点上结束……您是否安装了用于负载平衡的apache httpd?或者您刚刚设置了集群。192.168.0.1是主机的ip吗?如果你回答我,我会很高兴的。实际上我只需要故障转移
String name = "ejb:/test//TestEJB!" + TestEJBRemote.class.getName();
TestEJBRemote remote = (TestEJBRemote) ctx.lookup(name);
remote.test();
Properties properties = new Properties();
properties.put("endpoint.name", "farecompare-client-endpoint");
properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
properties.put("remote.connections", "cmc5101,cmc5102");
properties.put("remote.connection.cmc5101.host", "cmc5-101");
properties.put("remote.connection.cmc5101.port", "4447");
properties.put("remote.connection.cmc5101.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
properties.put("remote.connection.cmc5102.host", "cmc5-102");
properties.put("remote.connection.cmc5102.port", "4447");
properties.put("remote.connection.cmc5102.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
PropertiesBasedEJBClientConfiguration configuration = new PropertiesBasedEJBClientConfiguration(properties);
final ContextSelector ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(configuration);
final ContextSelector previousSelector = EJBClientContext.setSelector(ejbClientContextSelector);
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);