java - Stateless EJB and clustering -
scenario: ejba , ejbb both remote stateless session beans.
@stateless public class ejba { @ejb private ejbb b; public void foo(){ b.method1(); b.method1(); b.method2(); } }
is correct of these method calls on b can happen on different node/vm in clustered environment?
even calls method1?
i mean if client calls method foo, can happen in transaction method1 called on node1 , next call method1, during same invocation of foo(), goes ejb instance on node2?
interpreting following quote "enterprise javabeans 3.1":
"... each invocation upon slsb proxy operates independently both before , after. in fact, underlying bean instances may swapped interchangeably between requests."
i yes.
is there way ensure these calls happen same stateless session bean instance on same node/vm?
if right first assumption, should not possible.
e.g. using singleton ensures ejb unique per vm. in clustered environment doesn't give me guarentee.
is correct of these method calls on b can happen on different node/vm in clustered environment?
yes, method calls can remote - long have properly setup remote interface on ejbb
even calls method1?
i mean if client calls method foo, can happen in transaction method1 called on node1 , next call method1, during same invocation of foo(), goes ejb instance on node2?
interpreting following quote "enterprise javabeans 3.1":
"... each invocation upon slsb proxy operates independently both before , after. in fact, underlying bean instances may swapped interchangeably between requests."
i yes.
i 100% agree assessment. in fact, container implementors free create , destroy stateless session beans on each method invocation -- independent eachother.
is there way ensure these calls happen same stateless session bean instance
you'd have make ejb @singleton. way ensure it's created once per ejb container classloader
on same node/vm?
yes can make sure calls local - not define remote interface. by default ejbs expose local interfaces; meaning if don't work - you're calling local ejbs.
there's no reliable way "force" independent method calls handled same stateless bean. if you're trying maintain "conversational state" between ejba , ejbb stateful session bean for. stateful session bean, method invocations not guaranteed handled the same bean ejbb able remember state between method calls ejba. in setup ejbb dedicated specific instance of ejba , not serve other clients until ejba ends session - being destroyed example.
Comments
Post a Comment