-
1. Re: Client calling clustered EJB in same JVM
slaboure Sep 15, 2004 6:38 AM (in response to arnold)why do you want to change this behaviour? which use case?
-
2. Re: Client calling clustered EJB in same JVM
arnold Sep 15, 2004 7:02 AM (in response to arnold)Thanks for the prompt response.
OK, EJB X is a wrapper to a set of services provided by our EJBs.
The calculation service provided by Y is CPU intensive, so we clustered it to take advantage of load balancing.
There are two use cases w.r.t. accessing the calculation service of Y:
1. via a convenience wrapper EJB X from client on different VM
2. directly accessing Y from client on different VM
Clustering EJB X is probably out of the question, thus I am seeking a solution with changing the invocation stack. -
3. Re: Client calling clustered EJB in same JVM
slaboure Sep 15, 2004 8:10 AM (in response to arnold)the easiest is to run two instances of jboss on the same machine then.
Cheers,
sacha -
4. Re: Client calling clustered EJB in same JVM
dbuch Sep 15, 2004 9:18 AM (in response to arnold)I also interested on a solution to fix this problem.
I have a singleton MBean that starts CPU intensive processes. This processes calls EJBs but at this time only localy. It is important that the work is done in the cluster.
Thanks a lot
Dirk -
5. Re: Client calling clustered EJB in same JVM
arnold Sep 15, 2004 9:27 AM (in response to arnold)I am not sure how running multiple instances of JBoss would help my situation (for clustering EJBs I am running multiple instances of JBoss already).
Basically, is there a way to configure the invocation stack to NOT use the local calling protocol? -
6. Re: Client calling clustered EJB in same JVM
slaboure Sep 15, 2004 9:44 AM (in response to arnold)no.
split the "LB" ejb from the "workers" ejb.
cheers,
sacha -
7. Re: Client calling clustered EJB in same JVM
arnold Sep 16, 2004 12:26 PM (in response to arnold)Hi dbuch,
What avenue have you tried in solving your problem? -
8. Re: Client calling clustered EJB in same JVM
dbuch Sep 17, 2004 9:44 AM (in response to arnold)Hi arnold,
I have found a solution that fix the problem.
1. Create this classespublic class MyInvokerInterceptor extends InvokerInterceptor implements Externalizable { public MyInvokerInterceptor() { super(); } public boolean isLocal() { return false; } } public class MyMarshallingInvokerInterceptor extends MarshallingInvokerInterceptor { public boolean isLocal() { return false; } } public class MyJRMPInvokerProxyHA extends JRMPInvokerProxyHA { public MyJRMPInvokerProxyHA() { super(); } public MyJRMPInvokerProxyHA(ArrayList replicants, LoadBalancePolicy policy, String familyName, long currentViewId) { super(replicants, policy, familyName, currentViewId); } public boolean isLocal(Invocation invocation) { return false; } } public class MyJRMPInvokerHA extends JRMPInvokerHA { public Invoker createProxy(ObjectName beanName, LoadBalancePolicy policy, String proxyFamilyName) throws Exception { Integer hash = new Integer(beanName.hashCode()); HATarget target = (HATarget) beanMap.get(hash); if (target == null) { throw new IllegalStateException("The bean hashCode not found"); } String familyName = proxyFamilyName; if (familyName == null) familyName = target.getAssociatedPartition().getPartitionName() + "/" + beanName; MyJRMPInvokerProxyHA proxy = new MyJRMPInvokerProxyHA(target.getReplicants(), policy, familyName, target.getCurrentViewId()); return proxy; } }
2. create a jar file and copy it in to the <JBOSS_HOME>/server/lib directory. IMPORTANT: This file is also needed by the clients.
3. change 'org.jboss.invocation.jrmp.server.JRMPInvokerHA' to MyJRMPInvokerHA in the cluster-service.xml
4. change 'org.jboss.invocation.InvokerInterceptor' and 'org.jboss.invocation.MarshallingInvokerInterceptor' to MyInvokerInterceptor resp. MyMarshallingInvoker. I have only changed invoker-proxy-binding tags with name clustered-stateless-rmi-invoker, clustered-statefull-rmi-invoker, stateless-rmi-invoker and statefull-rmi-invoker. This can be done in the standardjboss.xml file or in a jboss.xml file (read the docu for this).
I hope this can help you.
Dirk -
9. Re: Client calling clustered EJB in same JVM
arnold Sep 17, 2004 10:02 AM (in response to arnold)Hi dbuch,
Thanks a lot for your help.
I also have a similar 'hack' which involed patching jbosshar.jar (I only changed InvokerInterceptor and JRMPInvokerProxyHA).
Personally, I don't like such hacks as it requires maintainence from our side (e.g. what if we want to switch to another version of JBoss?)
Sacha's suggestion of running separate JBoss might be better for portability and future proofing.
Thanks again,
Arnold