0 Replies Latest reply on Jan 21, 2017 10:11 AM by Andreas S

    [Wildfly 10.1.0] Loadbalancing EJB with SLSBs in Standalone Cluster with one host-name in ejb client

    Andreas S Newbie

      Hello,

       

      i want to build the following setup:

       

      * 2 Wildfly 10.1.0 Servers

      * Clusted via UDP

      * Both running an simple Application with one SLSB to use

      * The lookup should be done via only one hostname defined in the jboss-ejb-client.properties

       

      The Cluster:

      I have two Wildfly 10.1.0 servers running in two different Virtualbox instances. Both are started up with the standard full-ha profile distributed with the app server. The only exception was editing the settings for the private interface to allow clustering

       

      Server one:

      ./standalone.sh -c standalone-full-ha.xml -b 192.168.10.58 -u 230.0.0.4 -Djboss.node.name=testsystem01

       

      Server two:

      ./standalone.sh -c standalone-full-ha.xml -b 192.168.10.59 -u 230.0.0.4 -Djboss.node.name=testsystem02

       

      Both machines start up and find each other on the cluster:

       

      15:38:32,753 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (thread-4,ee,testsystem02) ISPN000094: Received new cluster view for channel ejb: [testsystem02|5] (2) [testsystem02, testsystem01]

       

      Now i'll deploy the application on both machines

       

       

      The Application

       

      SLSB:

       

      @Stateless
      @Remote
      @Clustered
      public class SimpleTestServiceBean implements SimpleTestService {

         public String getHelloWorld() {

         try {

         return "HelloWorld! on:" + InetAddress.getLocalHost().getHostName();
         } catch (UnknownHostException e) {

        e.printStackTrace();
         }

       

         return "";
         }

      }

       

       

      The Client

       

      EJB-Client

       

      public class RemotingClientMain {

       

         private static final String JNDI_NAME = "ejb:simple-wf-service-impl-ear-1.0.0-SNAPSHOT/simple-service/SimpleTestServiceBean!org.dev.wildfly.service.SimpleTestService";

        public static void main(String[] args) throws Exception {

        SimpleTestService service = lookupWithInitialContext();
         service.getHelloWorld();
        for(int i = 0; i < 10000; i++)

        System.out.println(service.getHelloWorld());
         }

       

         private static SimpleTestService lookupWithInitialContext() throws Exception {

         final Hashtable<String, String> jndiProperties = new Hashtable<>();
         jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

         InitialContext ctx = new InitialContext(jndiProperties);
         SimpleTestService bean = (SimpleTestService)ctx.lookup(JNDI_NAME);

        return bean;
         }

      }

       

      jboss-ejb-client.properties:

       

      remote.connections=default
      remote.connection.default.host=192.168.10.58
      remote.connection.ejb.clusternode.selector=org.jboss.ejb.client.RandomClusterNodeSelector
      remote.connection.default.port=8080
      remote.connection.default.protocol=http-remoting
      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
      remote.connection.default.username=test
      remote.connection.default.password=test

       

      The Problem:

       

      If i now start the client application the lookup succeeds and the calls are executed on testsystem01, the first node. If i now, put the first node down, i would expect, that the proxy in the client executes the calls on testsystem02, the second node. But the client crashes either with

       

      EJBCLIENT000025: No EJB receiver available for handling [appName:simple-wf-service-impl-ear-1.0.0-SNAPSHOT, moduleName:simple-service, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@b3f36ab

       

      if i undeploy the application on testsystem01 or with

       

      Exception in thread "main" java.lang.IllegalStateException: WFLYEE0043: Component is stopped

       

      if i shut down the server. Also if both servers are up, the calls only get executed on the first node. There is no balancing to the second one

       

      What do i expect?

       

      I am expecting that the ejb client works as follows:

       

      * The proxy is build without any connection to the server

      * As the first call to the "getHelloWorld()" method is executed, the ejb client gets the cluster view from the initial server and holds it, until the connection is closed

      * If any node, even the initial node, is going down, the calls are executed on the servers as defined by the cluster view

       

      Could my assumption be wrong and the whole thing is not going to work as i understand?

       

      What do i want to archive with this setup?

       

      I want to make sure, that a client, which wants to call the server application has to know as little hostnames as possible, so i can scale my server cluster without any knowledge of the client application. Just similar to use mod_jk as a loadbalancer for http calls.

       

      So, as written before, it might be the situation, that the way i expected my setup to is not possible and there are better solutions to archive this.

      I would be very grateful if anyone can help me with this

       

      Thanks,

      Andreas

       

      Edit:

      Changed Title

      Fixed typo