-
1. Re: round robin on Jboss 5
brian.stansberry Jan 19, 2009 11:40 AM (in response to yairogen)What kind of client? EJB 2? EJB3? JMS?
-
2. Re: round robin on Jboss 5
yairogen Jan 20, 2009 2:07 AM (in response to yairogen)I am using EJB 3.
-
3. Re: round robin on Jboss 5
brian.stansberry Jan 20, 2009 11:04 AM (in response to yairogen)Do you have an @org.jboss.ejb3.annotation.Clustered annotation on the bean classes, or
<clustered>true</clustered>
in each bean's section in the ejb jar's jboss.xml? -
4. Re: round robin on Jboss 5
yairogen Jan 21, 2009 2:53 AM (in response to yairogen)No, I don't use this annotation. Trying to add it gave me errors as I recall. This should be added on the bean class and not the interface, right?
I haven't tried adding the clustered true node in the jboss.xml file. I don't have such a file.
Are you referring to the "standardjboss.xml" file?
If yes, where do I add this node? If not which file are you referring to?
Thanks. -
5. Re: round robin on Jboss 5
brian.stansberry Jan 21, 2009 10:36 AM (in response to yairogen)"yairogen" wrote:
No, I don't use this annotation. Trying to add it gave me errors as I recall. This should be added on the bean class and not the interface, right?
Correct.I haven't tried adding the clustered true node in the jboss.xml file. I don't have such a file.
Are you referring to the "standardjboss.xml" file?
If yes, where do I add this node? If not which file are you referring to?
The jboss.xml file is the jboss-specific deployment descriptor that you add to your EJB jar's META-INF directory. The schema can be found in the docs/schema/jboss_5_0.xsd file in your JBoss AS distribution.
A simple example:<?xml version="1.0"?> <jboss xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss_5_0.xsd" version="3.0"> <enterprise-beans> <session> <ejb-name>ExampleStateful</ejb-name> <jndi-name>ExampleStatefulRemote</jndi-name> <clustered>true</clustered> <cluster-config> </session> </enterprise-beans> </jboss>
-
6. Re: round robin on Jboss 5
yairogen Jan 22, 2009 2:36 AM (in response to yairogen)Thank you for your reply.
Just to set things strait - the 2 options are equivalent? I can either use annotations and then no need to use the xml file, or I add the xml file and then I must declare my ejb in that file?
correct? -
7. Re: round robin on Jboss 5
yairogen Jan 22, 2009 7:53 AM (in response to yairogen)Another question:
I must change the file "messaging-service.xml" manually and change the id of the "ServerPeerID" element.
Is this the correct thing for me to do? Is it really a must?
I didn't find any documentation on this subject. -
8. Re: round robin on Jboss 5
yairogen Jan 22, 2009 7:58 AM (in response to yairogen)When the cluster is on with 2 nodes I see load balancing nicely.
When I take one node down the other continues to work fine, But when I start up again the failed node it doesn't handle the requests that continue to get in. Only the first non failed node continues working.
Why is this happening? I would assume that the second node that is now up should participate in the load balancing again.
Am I missing something? -
9. Re: round robin on Jboss 5
brian.stansberry Jan 22, 2009 10:48 AM (in response to yairogen)Yes, the annotation and the xml are equivalent; no need to use both.
Re: messaging-service.xml, don't change the file, but yes, in a cluster every server needs a distinct value for the ServerPeerID property. The file uses system property substitution syntax:<attribute name="ServerPeerID">${jboss.messaging.ServerPeerID:0}</attribute>
so you can set the value from the command line and don't have to edit the file:sh run.sh -c all -b someaddress -Djboss.messaging.ServerPeerID=1
Re: your failover behavior:
1) What AS release?
2) Please confirm that the nodes form a cluster after you restart. You can see the view (i.e. group membership) in the jboss:service=DefaultPartition mbean in the jmx-console. It's also logged in server.log.
3) If you have a proper two-node view, then I'll need more details on how your app works, preferably code showing how the client looks up the bean in JNDI, what it does with the naming Context reference, what it does with the bean reference, plus info on how many threads, etc. -
10. Re: round robin on Jboss 5
yairogen Jan 25, 2009 2:46 AM (in response to yairogen)"bstansberry@jboss.com" wrote:
1) What AS release?
The AS version is: jboss-5.0.0.GA"bstansberry@jboss.com" wrote:
2) Please confirm that the nodes form a cluster after you restart. You can see the view (i.e. group membership) in the jboss:service=DefaultPartition mbean in the jmx-console. It's also logged in server.log.
Yes. I clearly see in the server logs that there are 2 members in the group."bstansberry@jboss.com" wrote:
3) If you have a proper two-node view, then I'll need more details on how your app works, preferably code showing how the client looks up the bean in JNDI, what it does with the naming Context reference, what it does with the bean reference, plus info on how many threads, etc.
I am using a Spring injection for my client. This may be the problem? I am using the "org.springframework.jndi.JndiObjectFactoryBean" object. I heard that there is something called: "Cluster Aware" Spring proxy that JBoss can offer. Is this true? Can you point me to this object? -
11. Re: round robin on Jboss 5
brian.stansberry Jan 26, 2009 4:50 PM (in response to yairogen)Can you post the relevant section of your Spring config? Easier than asking 20 questions. :) The docs for the JndiObjectFactoryBean imply it will do the lookup once and cache it.
My guess about what you are doing is you are creating a client and using JndiObjectFactoryBean to handle the JNDI lookup, which means you are ending up with a single bean instance in your client. And you want the requests load-balanced, which tells me its a stateless bean. -
12. Re: round robin on Jboss 5
brian.stansberry Jan 26, 2009 4:51 PM (in response to yairogen)"bstansberry@jboss.com" wrote:
Easier than asking 20 questions. :)
I meant easier than me asking 20 questions. :) -
13. Re: round robin on Jboss 5
yairogen Jan 27, 2009 2:23 AM (in response to yairogen)Thanks.
Here is the spring stuff:<bean id="EjbService" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiEnvironment"> <props> <prop key="java.naming.factory.initial">${java.naming.factory.initial} </prop> <prop key="java.naming.factory.url.pkgs">${java.naming.factory.url.pkgs} </prop> <prop key="java.naming.provider.url">${java.naming.provider.url} </prop> </props> </property> <property name="jndiName" value="ejb/jndiName" /> </bean>
Can you tell me something about a replacement?
Maybe a JBoss spring bean? I heard there is something of the sort that is Cluster aware. -
14. Re: round robin on Jboss 5
brian.stansberry Jan 27, 2009 1:18 PM (in response to yairogen)"yairogen" wrote:
Can you tell me something about a replacement?
Maybe a JBoss spring bean? I heard there is something of the sort that is Cluster aware.
Not that I know of, but there are lots of things out there.
Anyway, looking at your config and the JndiObjectFactoryBean code, I don't see any issue there. It's doing a single lookup of the EJB proxy, so any code you have that uses your "EjbService" Spring bean is using that single EJB proxy. So the behavior you are seeing suggests a problem in the JBoss clustering code, e.g. the proxy is not getting properly updated with the new cluster topology after you restart the node. I'll see if I can reproduce.
I'm assuming this is an Stateless Session Bean; correct me if I'm wrong.