liangcmwn

          CACHING - How to implement "Distributed cache clearing" in Ofbiz?

          We have multiple instances of Ofbiz/Opentaps running. All the instances talk to same database. There are many tables that are rarely updated hence the are cached and all the instances maintain their individual copies of cache as a standard Ofbiz cache mechanism. But in rare situations when we update some entity using one of many instances then all other instances keep showing dirty cache data. So it requires a manual action to go and clear all the cache copies on other instances as well.

          I want this cache clearing operation on all the instances to happen automatically. On Ofbiz confluence page here there is a very brief mention of "Distributed cache clearing". It relies on JMS it seems so whenever an instance's cache is cleared it sends notification over JMS to a topic and other instances subscribing to same JMS topic clear their corresponding copies of cache upon this notification. But I could not find any other reference or documentation on how to do that? What are the files that need to be updated to set it all up in Ofbiz. An example page/link is the what I'm looking for.


          Answer


          Alright I've figured it all out. I have used ActiveMQ as my JMS broker to set it up so here are the steps in Ofbiz to make it working:

          1. Copy activemq-all.jar to framework/base/lib folder inside your Ofbiz base directory.

          2. Edit File base/config/jndiservers.xml: Add following definition inside <jndi-config> tag:

             <jndi-server name="activemq"
               
          context-provider-url="failover:(tcp://jms.host1:61616,tcp://jms.host2:61616)?jms.useAsyncSend=true&amp;timeout=5000"
               
          initial-context-factory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
               
          url-pkg-prefixes=""
               
          security-principal=""
               
          security-credentials=""/>

          3. Edit File base/config/jndi.properties: Add this line at the end:

          topic.ofbiz-cache=ofbiz-cache

          4. Edit File service/config/serviceengine.xml: Add following definition inside <service-engine> tag:

              <jms-service name="serviceMessenger" send-mode="all">
                 
          <server jndi-server-name="activemq"
                 
          jndi-name="ConnectionFactory"
                 
          topic-queue="ofbiz-cache"
                 
          type="topic"
                 
          listen="true"/>
             
          </jms-service>

          5. Edit File entityengine.xml: Change default delegator to enable distributed caching:

          <delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="true">

          6. Edit File framework/service/src/org/ofbiz/service/jms/AbstractJmsListener.java: This one is probably a bug in the Ofbiz code

          Change following line from:

          this.dispatcher = GenericDispatcher.getLocalDispatcher("JMSDispatcher", null, null, this.getClass().getClassLoader(), serviceDispatcher);

          To:

          this.dispatcher = GenericDispatcher.getLocalDispatcher("entity-default", null, null, this.getClass().getClassLoader(), serviceDispatcher);

          7. And finally build the serviceengine code by issuing following command:

          ant -f framework/service/build.xml

          With this entity data changes in Ofbiz on one instances are immediately propagated to all the other Ofbiz instances clearing cache line item on its own without any need of manual cache clearing.


          From:

           

          http://efreedom.com/Question/1-4865827/Implement-Distributed-Cache-Clearing-Ofbiz

           

          posted on 2011-08-25 13:56 liangcmwn 閱讀(297) 評(píng)論(0)  編輯  收藏 所屬分類: Ofbiz


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 随州市| 大厂| 河北省| 同德县| 沙河市| 陵川县| 志丹县| 台安县| 麻栗坡县| 八宿县| 麟游县| 武安市| 开化县| 汨罗市| 定远县| 郑州市| 胶州市| 垣曲县| 土默特右旗| 双柏县| 济南市| 行唐县| 新宁县| 辽中县| 呈贡县| 长岭县| 蕉岭县| 灌南县| 开远市| 寿阳县| 蒙山县| 昔阳县| 灵宝市| 伊宁市| 获嘉县| 三台县| 观塘区| 丰台区| 土默特左旗| 临湘市| 天台县|