-
15. Re: Cluster to Cluster EJB Call
gwwallace May 7, 2012 3:31 PM (in response to jaikiran)jboss-ejb3.xml
<jboss xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:jee="http://java.sun.com/xml/ns/javaee"
xmlns:c="urn:clustering:1.0">
<jee:assembly-descriptor>
<c:clustering>
<jee:ejb-name>LocationModuleSessionBean</jee:ejb-name>
<c:clustered>true</c:clustered>
</c:clustering>
</jee:assembly-descriptor>
</jboss>
Session Bean
@Stateless
@Remote(LocationModuleAPI.class)
public class LocationModuleSessionBean implements LocationModuleAPI {
private static final int SLEEP_TIME_WAITING_FOR_DELEGATE = 1000;
private static final long MAXIMUM_WAIT_FOR_DELEGATE = 2 * 60 * 1000; //two minutes
@Resource(name="module.name")
private String _moduleName;
private LocationModuleAPI _delegate;
public LocationModuleSessionBean() {
}
protected Log getLog() {
return LogFactory.getLog( getClass() );
}
@PostConstruct
public void init() {
try {
_delegate = (LocationModuleAPI) ModuleLookupService.getInstance().lookupModule(_moduleName);
}
catch (ModuleLookupException ne) {
ne.printStackTrace();
}
}
/ * All methods below here - just delegate to _delegate */
-
16. Re: Cluster to Cluster EJB Call
gwwallace May 8, 2012 10:58 AM (in response to gwwallace)Jaikiran,
Did you have a chance to look at this again ?
thanks
Graeme
-
17. Re: Cluster to Cluster EJB Call
jaikiran May 8, 2012 11:42 AM (in response to gwwallace)Graeme Wallace wrote:
Jaikiran,
Did you have a chance to look at this again ?
Will do today - was caught up with other important tasks yesterday.
-
18. Re: Cluster to Cluster EJB Call
jaikiran May 8, 2012 2:02 PM (in response to jaikiran)I just tested this against the latest build and it works fine. Could you attach that application which reproduces this issue for you, along with the entire server logs (I guess you forgot to attach the logs in your earlier post)?
-
19. Re: Cluster to Cluster EJB Call
gwwallace May 8, 2012 2:30 PM (in response to jaikiran)Ok. Let me skinny the code up for you as you wont want all the dependencies the real system has.
-
20. Re: Cluster to Cluster EJB Call
gwwallace May 8, 2012 11:54 PM (in response to gwwallace)Here's an example i've hacked up.
If you add jboss-client.jar to the lib dir, it should compile and produce a couple of ear files and jars.
farecompare-cluster-server.ear is deployed on cmc5-101 and cmc5-102
farecompare-relay-server.ear is deployed on cmc5-103
farecompare-client.jar is a standalone client that makes a non clustered EJB connection to the relay server
In the process of doing this however, I've found that cmc5-101 and cmc5-102 no longer behave like they are in a cluster,
even though i've started them both with standalone-ha.xml. Failover doesnt even work now.
Is there some extra config you have to do in 7.1.2 ?
-
jboss7example.tgz 107.5 KB
-
-
21. Re: Cluster to Cluster EJB Call
jaikiran May 9, 2012 3:11 AM (in response to gwwallace)There's a bug in your application packaging which is causing this issue. The jboss-ejb3.xml (which is meant for JBoss specific overrides for the ejb-jar.xml/annotations) is expected to be alongside the ejb-jar.xml in the META-INF of EJB jar and _not_ in the META-INF of the .ear. It's jboss-ejb-client.xml (which is a JBoss specific descriptor file for remote EJB client configurations) which is expected to be in the META-INF of the .ear (or WEB-INF of top level .war deployments). Once I fixed your build.xml to package this correctly, the clustering configuration in your jboss-ejb3.xml started taking effect and your round robin cluster node selector started being used. I've attached a modified version of your application (fixed the build.xml and added some System.out.println statements in some parts of the code to illustrate that both clustering failover and clustering loadbalancing is working).
-
jboss7example-fixed.tar.gz 3.2 MB
-
-
22. Re: Cluster to Cluster EJB Call
jaikiran May 9, 2012 3:16 AM (in response to jaikiran)By the way, here's the log which shows loadbalancing is working (the reference to "one" corresponds to cmc5-103 relay app, two corresponds to cmc5-101 cluster app and three corresponds to cmc5-102 cluster app)
12:33:42,258 INFO [stdout] (EJB default - 1) Relay module session bean invoked on one --> first invocation when clustering topology hasn't yet been received 12:33:53,593 INFO [stdout] (EJB default - 2) Relay module session bean invoked on one --> at this point clustering topology has been received, so the cluster node selector will be called 12:33:53,595 INFO [stdout] (EJB default - 2) RoundRobin::selectNode ejb ConnectedNodes: [two, three] AvailableNodes: [two, three] -->cluster node selector invoked 12:34:13,496 INFO [stdout] (EJB default - 3) Relay module session bean invoked on one 12:34:13,497 INFO [stdout] (EJB default - 3) RoundRobin::selectNode ejb ConnectedNodes: [two, three] AvailableNodes: [two, three] 12:34:25,596 INFO [stdout] (EJB default - 4) Relay module session bean invoked on one 12:34:25,598 INFO [stdout] (EJB default - 4) RoundRobin::selectNode ejb ConnectedNodes: [two, three] AvailableNodes: [two, three] 12:34:38,281 INFO [stdout] (EJB default - 5) Relay module session bean invoked on one 12:34:38,282 INFO [stdout] (EJB default - 5) RoundRobin::selectNode ejb ConnectedNodes: [two, three] AvailableNodes: [two, three]
Then I take down cluster node "two" and here's the rest of the failover log which shows updated topology and the load balancer being invoked:
12:34:46,412 INFO [org.jboss.ejb.client.remoting] (Remoting "one" task-4) EJBCLIENT000016: Channel Channel ID ed696301 (outbound) of Remoting connection 011ff1b8 to localhost.localdomain/127.0.0.1:4547 can no longer process messages 12:34:55,825 INFO [stdout] (EJB default - 6) Relay module session bean invoked on one 12:34:55,826 INFO [stdout] (EJB default - 6) RoundRobin::selectNode ejb ConnectedNodes: [three] AvailableNodes: [three]
-
23. Re: Cluster to Cluster EJB Call
gwwallace May 9, 2012 9:18 AM (in response to jaikiran)Thanks Jaikiran ! Its always something stupid - i must have had that correct at some point then bollocksed it up.
I have one last question regarding the standalone client - in the code there is a line
final ContextSelector<EJBClientContext> previousSelector = EJBClientContext.setSelector(ejbClientContextSelector); This appears not to be thread safe, as the setSelector could be called in another thread before the JNDI lookup is done.
Is this really the case ?
Thanks again for your help,
Graeme
-
24. Re: Cluster to Cluster EJB Call
arnoldjohansson May 9, 2012 10:52 AM (in response to jaikiran)Hi!
Great explanations Jaikiran!
I'm having similar issues with yesterdays (downloaded 2012-05-08, 08:41 CET) 7.1.2.Final-SNAPSHOT, but here the selectNode() method of the ClusterNodeSelector-implementation is not getting called. The constructor is called though! Is this a known issue?
KR
/Arnold
-
25. Re: Cluster to Cluster EJB Call
jaikiran May 15, 2012 6:41 AM (in response to arnoldjohansson)Arnold, sorry I forgot to reply to your question. Are you still running into this? If yes, could you please create a separate thread with relevant details about the issue you are running into?
-
26. Re: Cluster to Cluster EJB Call
jaikiran May 15, 2012 6:53 AM (in response to gwwallace)Graeme Wallace wrote:
I have one last question regarding the standalone client - in the code there is a line
final ContextSelector<EJBClientContext> previousSelector = EJBClientContext.setSelector(ejbClientContextSelector); This appears not to be thread safe, as the setSelector could be called in another thread before the JNDI lookup is done.
Is this really the case ?
That really isn't a "thread safety" issue. What you are looking for is a way to lock down the selector so that it cannot be changed. That's possible, you can use:
EJBClientContext.lockSelector();
to do that.
-
27. Re: Cluster to Cluster EJB Call
arnoldjohansson May 15, 2012 10:05 AM (in response to jaikiran)Hi!
Yes, I've got the same problem in AS7.1.2.Final.
I've created a new thread here: https://community.jboss.org/thread/199715
Thanks
/Arnold