2 Replies Latest reply on Jan 9, 2003 4:23 AM by slaboure

    EntityBean client-side cache

    philc

      Current cache
      I wrote a client side cache mechanism using JMS and XML six months ago. I'm running into limitations where I find myself recreating a data object framework on the client side to mimic ejb features such as primary keys and relationships.

      Here's a brief overview:

      1. Initial Data Object tree is sent to the client by calling a SessionBean method.

      2. The client subsribes to a JMS topic and gets data updates in the form: (order has a one-to-many relationship to detail)
      [pre]
      <order pk=123>
      rocket

      <detail pk=345>
      junk
      20021223

      <detail pk=346>
      love
      20021223



      [/pre]

      3. The client parses the xml and updates it's copy of the data objects.

      The cache is not invalidated, it is updated so that the client never has to wait for an update from the server to display data. The data on the client side is always considered to be up-to-date. JMS message are built and sent by a Server-side Interceptor which catches calls to "set" methods.

      The problem as I mentioned earlier is that the system is based on data objects.

      Dream cache
      What I would prefer, is a cache mecanism based on Remote EntityBeans instead of DataObject. The Remote EntityBean would be set up with Client side interceptors that would return values without going to the server.
      The cache would also be updated by JMS messages or JavaGroups.

      My questions are:
      Does a cache system like this already exist?
      If not what building blocks should I use to build it?

      Philippe

        • 1. Re: EntityBean client-side cache
          belaban

          Hi Philippe,

          I'm not shooting that high. The cache that I have in mind should not do much besides replicating its data (doesn't apply for the local cache), and acquiring the cache state from othes in the cluster when coming up.
          This will be an MBean. Note that I'm not even mentioning entity beans at this point: the cache is J2EE agnostic.

          We can then go ahead and create more elaborate caches, which use the simple functionality offered by the cache. What you described could very well be implemented with this simple cache.

          This simple cache already exists (org.javagroups.blocks.TransactionalHashtable), but I have to port it to JBoss first, and work on the locking stuff. The hooks are in place, but not yet the implementation.

          Bela

          • 2. Re: EntityBean client-side cache
            slaboure

            Note that if the number of clients or if the number of update is high, this kind of optimisation will not scale.

            Maybe you are trying to mimic a 2-tiers system in a n-tiers environment. Why not let the app servers do the caching on the app server side and have the client request information. For client-specific beans (such as SFSB), then yes, it is possible to do client-side caching (in the proxy) or, if the client manages the transaction, we could also do that for some entity beans. Nevertheless, the client will, in most cases, never directly access entity beans remotly.

            cheers,


            sacha