Forums Register Login

For clustering, should I use Remote/Local Interface for EJB ?

+Pie Number of slices to send: Send
Dear all,

We I used clustering. I mean I deploy a ejb module into multiple servers (clustering).
Should I code this ejb against remote/local?

What I concerned is that if i code this ejb against local.
the ejb modules could not keep sync on different servers on cluster.

Thanks and Rgds

Rgds
Wang Yan
+Pie Number of slices to send: Send
I may not understand your description correctly but it sounds like you are under the impression that adding remote interfaces to your EJBs will inherently give them the capability of automatically synchronizing their data over multiple JVMs and servers - it does not. In regards to your situation you may want to ponder the following points:
  • First Law of Distributed Object Design: Don't distribute your objects! (Martin Fowler, PEAA p.89). So your application itself should be designed so that it is stateless. If there is any state necessary, identify the smallest possible subset and attach this "data-context" to every message between the client and the server. Of course, there are cases where this "context" can become too large.
  • Avoid giving entity java beans a remote interface - use a Session Facade instead. Once you design the session facade you may find that you really don't need the entity beans anymore.
  • Avoid using stateful session beans if you can. If it is necessary to maintain state between the client and the server, maintain that state in an HttpSession in the web tier. HttpSessions are easier to migrate from one server to another when necessary.
  • While on an API level local and remote interfaces may look very similar - they do exist for totally different reasons. The local interfaces are used for finer-grained interfaces between domain objects that reside on the same server but may want to take advantage of some of the EJB container's services (otherwise they should simply be POJOs). The remote interfaces are used for coarse-grained interfaces; much less like an object interface but more like a service interface (that uses an entire domain model to process a request). So, if you are looking at an enterprise bean that exposes the same interface locally and remotely then you are most likely looking at an inappropriate design.

  • For more advice along these lines consult Expert One-on-One J2EE Design and Development (Even chapter 1 contains useful information).
    [ September 13, 2005: Message edited by: Peer Reynders ]
    +Pie Number of slices to send: Send
    Bear in mind that the certification exam does not test you on clustering.
    I do some of my very best work in water. Like this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 747 times.
    Similar Threads
    DecisionTable: Cluster, Inter-EJB, Local, Intra-Tier/Team, RowSet, ValueObject, ...
    Remote Transactions
    caching local objects
    Local Objects
    please help for clustering it requires remote or local interface?
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 18, 2024 21:50:55.