-
1. Re: 7.1.1 - Clustered Stateless Session Beans
jaikiran Mar 15, 2012 10:49 PM (in response to gwwallace)Graeme Wallace wrote:
When i run multiple instances of my client app
Multiple instances of client app?
What does the code look like? And is the client application a standalone application?
-
2. Re: 7.1.1 - Clustered Stateless Session Beans
gwwallace Mar 15, 2012 11:59 PM (in response to jaikiran)Here's the standalone client code.
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); LocationModuleAPI locationModule = (LocationModuleAPI) context.lookup( "ejb:locationmodule/xxi-framework-location-finder-module-ejb//LocationModuleSessionBean!com.xxi.framework.locationfindermodule.api.LocationModuleAPI"); LineNumberReader lReader = new LineNumberReader(new InputStreamReader(System.in)); for (;;) { System.out.print("City Code: "); System.out.flush(); String cityCode = lReader.readLine(); CityLocation cityLocation = locationModule.getCity(cityCode); System.out.println(cityLocation.getCityLocationName()); }
-
3. Re: 7.1.1 - Clustered Stateless Session Beans
gwwallace Mar 16, 2012 5:58 PM (in response to gwwallace)Anyone care to chime in ?
-
4. Re: 7.1.1 - Clustered Stateless Session Beans
rhusar Mar 18, 2012 5:46 PM (in response to gwwallace)I dont see anything obvious. Could you ensure that you have a significant amount of clients to make sure that the loadbalancing is not happening? It does make sense to reuse existing connection, rather than forcing round robin and having to either reinitiate TCP connections or just having too many open connections. Also, maybe try using @Clustered annotation on your class as there potentially be something wrong with the jboss ejb xml parsing.
-
5. Re: 7.1.1 - Clustered Stateless Session Beans
gwwallace Mar 18, 2012 6:45 PM (in response to rhusar)Thanks for the reply.
I take it then that load balancing is supposed to work ? Good.
Is there a way of specifying the load balancing policy that you know of ?
Also, I setup the client app on a bunch of different machines. Every instance connected to cmc5101, the first instance.
How many clients do you think it would take before it sent one request to the 2nd machine in the cluster ?
-
6. Re: 7.1.1 - Clustered Stateless Session Beans
jaikiran Mar 19, 2012 1:08 AM (in response to gwwallace)I just had a look at this and it appears that there's a bug in here. There appears to be a missing part to the implementation of https://issues.jboss.org/browse/AS7-3848. Please file a JIRA for this.
Graeme Wallace wrote:
Is there a way of specifying the load balancing policy that you know of ?
Take a look at https://docs.jboss.org/author/display/AS71/Clustered+EJBs for an initial introduction to how clustered EJBs work for a remote client. Furthermore, I'll just paste here a reply to a similar question, which I sent out internally last week:
If the client is talking to a clustered environment (clustered EJBs or clustered servers) like in your case, the jboss-ejb-client.properties is expected to configure: 1) Atleast one initial node to connect to (this is irrespective of whether it's clustered environment or not). 2) The connection configurations to use for auto connecting to the nodes within a cluster. This can be configured for _all_ nodes in a cluster or for individual nodes, separately, in a cluster. Typically, only configuring the connection configurations for the cluster level is enough since all nodes in that cluster might use the same connection configurations. But obviously, there will be cases where this won't be true. The configuration properties for the cluster are of the following form: Listing all clusters: remote.clusters=<comma separated list of cluster names> Configuration applicable for all nodes within a cluster: remote.cluster.<cluster-name>.connect.options.<connection-option>=<value> Example: remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false So all nodes within the cluster named "ejb" will use this connection option Configuration applicable for a specific node within a cluster: remote.cluster.<cluster-name>.node.<node-name>.connect.options.<connection-option>=<value> Example: remote.cluster.ejb.node.foo-node.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false Here we are configuring the connection configuration for a node named "foo-node" within a cluster named "ejb". The cluster name here is important and it should match the name of the cache-container which backs the @Clustered bean. By default it's "ejb" and is configured in the infinispan subsystem and is referred from the "cache-container" attribute of the cluster-passivation-store element in the EJB3 subsystem.
As for plugging in your own implementation of a load balancer, it's possible. By default, the EJB client implementation uses a RandomClusterNodeSelector https://github.com/jbossas/jboss-ejb-client/blob/master/src/main/java/org/jboss/ejb/client/RandomClusterNodeSelector.java. You can instead configure your own ClusterNodeSelector https://github.com/jbossas/jboss-ejb-client/blob/master/src/main/java/org/jboss/ejb/client/ClusterNodeSelector.java by setting the following property:
remote.cluster.<cluster-name>.clusternode.selector=<fully qualified name of the class which implements org.jboss.ejb.client.ClusterNodeSelector inteface>
-
7. Re: 7.1.1 - Clustered Stateless Session Beans
gwwallace Mar 19, 2012 9:47 AM (in response to jaikiran)Thanks for the reply.
I'll file a JIRA, but just to be sure - I'm presuming the bug is around not randomly choosing a client to connect to ?
-
8. Re: 7.1.1 - Clustered Stateless Session Beans
gwwallace Mar 19, 2012 4:14 PM (in response to gwwallace) -
9. Re: 7.1.1 - Clustered Stateless Session Beans
jaikiran Mar 20, 2012 1:44 AM (in response to gwwallace)Graeme Wallace wrote:
Thanks for the reply.
I'll file a JIRA, but just to be sure - I'm presuming the bug is around not randomly choosing a client to connect to ?
Thanks for filing the JIRA. I've added a comment in that JIRA to explain what's wrong.
-
10. Re: 7.1.1 - Clustered Stateless Session Beans
rohanemmanuel May 21, 2013 6:24 AM (in response to jaikiran)Hi Jaikiran Pai,
while invoking a SFSB(clustered) i had to add the following part to the jboss-ejb-client.properties file to solve the ERROR
ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed:
remote.clusters=ejb
remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED=false
remote.cluster.ejb.username=admin
remote.cluster.ejb.password=admin123
now if i see the jboss-ejb-client.properties file...i have given the username and password twice ,First time for the remote connection(remote.connection.default.username) and second time for the cluster (remote.cluster.ejb.username) .. is this the correct way?the username and password has to be mentioned twice?
if i remove the username and password from the clusters , the invocation works file but on the client side there will be the authentication error again.,,,
please advice,
Regards,
Rohan