Cluster SLSB load balancing.
gcontini May 23, 2011 9:29 AMHi!
I'm using jboss 6 and I'm trying to load balance remote ejb calls in a cluster. I want that some of the remote calls are routed on nodes other than the current one. (I have a TimerService deployed as a singleton and i want to load balance the batch load).
I've run into a problem that's documented here:
http://community.jboss.org/wiki/ClusteringFAQ "Why are calls between clustered session beans not load balanced even though load balancing policy is Round Robin?".
I don't want to undeploy some of the ejb from one of the containers, so i wrote my own interceptor as described in the wiki.
{code}
package acme;
import org.jboss.invocation.Invocation;
import org.jboss.invocation.InvokerInterceptor;
public class MyInvokerInterceptor extends InvokerInterceptor {
@Override
public boolean hasLocalTarget(final Invocation invocation) {
return false;
}
}
{code}
Then i tried to configure it in standardjboss.xml. I modified the "clustered-stateless-unified-invoker" replacing:
{noformat}
<interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
{noformat}
with:
{noformat}
<interceptor call-by-value="false">acme.MyInvokerInterceptor</interceptor>
{noformat}
and i've configured the correct "invoker-proxy-binding-name" in jboss.xml into my application jar, but yet remote calls always choose the same cluster node where they are generated.
I tried a completely different way modifying ejb3-interceptors-aop.xml, commenting out:
{noformat}
<interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>
{noformat}
at this point remote calls are load balanced and everything seem to work fine (in my sample i use no persistence yet) but i get the following exception:
{noformat}
12:48:31,049 ERROR [STDERR] java.lang.RuntimeException: cannot import a transaction context when a transaction is already associated with the thread
12:48:31,050 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:62)
12:48:31,050 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
{noformat}
How can i avoid this exception?
Gabriele