0

I'm trying to integrate Grails 2.1.1 with Terracotta and Ehcache but I'm not getting any good results whatsoever.

Could anybody give me some advice in order to configure it? I'm a little bit confused.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Analia
  • 1
  • 1

1 Answers1

0

Working on the subj now. First create ehcache.xml in your grails-app/conf directory. It should look like that:

<ehcache>                                                                                                                                                                                                                                      

 <terracottaConfig url="vm4:9510"/>                                                                                                                                                                                                           

  <defaultCache                                                                                                                                                                                                                                
      maxElementsInMemory="50"                                                                                                                                                                                                                 
      eternal="false"                                                                                                                                                                                                                          
      timeToIdleSeconds="20"                                                                                                                                                                                                                   
      timeToLiveSeconds="20"                                                                                                                                                                                                                   
      overflowToDisk="false"                                                                                                                                                                                                                   
      diskPersistent="false"                                                                                                                                                                                                                   
      memoryStoreEvictionPolicy="LRU"                                                                                                                                                                                                          
       />                                                                                                                                                                                                                                       

   <cache name="processedUrlCache"                                                                                                                                                                                                              
         maxElementsInMemory="50000"                                                                                                                                                                                                           
         eternal="true">                                                                                                                                                                                                                       
      <terracotta />                                                                                                                                                                                                                             
   </cache>                                                                                                                                                                                                                                     

</ehcache> 

Consider that terracottaConfig url should point to your actual host:port where Terracotta server lives. Make sure that your tarracotta cache node has <terracotta/> subnode (similarly to my processUrlCache entry).

Now, put these 3 jars into your project lib directory: ehcache-core-ee-2.6.2.jar, ehcache-terracotta-ee-2.6.2.jar, terracotta-toolkit-1.6-runtime-ee-5.2.0.jar

Actual version may differ (but it should be exactly the same as on your terracotta server, so my suggestion is to take those jars from server lib directories).

Now, run your server (start-tc-server.sh or start-tc-server.bat depending on Unix/Windows platform) and run your grails app. For the first start I would suggest you enabling debug logs in your Config.groovy file by putting

debug 'net.sf.ehcache'

into your log4j section.

Let me know would it help you.

Archer
  • 5,073
  • 8
  • 50
  • 96
  • Hey @archer, did you make any more progress / experiences with this? Currently working on such a setup and have to admit that it is hard to find good documentation! – fluxon Mar 05 '13 at 09:58
  • what kind of documentation you're looking for? – Archer Mar 06 '13 at 06:32
  • Hey archer! Thanks for getting back to me. I managed to set up the distributed 2nd level cache incl. session sharing now. But there is one thing that I find very inconvenient, maybe you have a hint for me: how do you handle working in local environments? I don't really want to setup a terracotta instance on all local machines. How do you do it? Just remove the config? – fluxon Mar 06 '13 at 15:14
  • 1
    I've setup one remote terracota instance and hardcode it location in all ehcache.xml files working in local dev envoronments. That's simple, man ;) – Archer Mar 07 '13 at 12:17
  • True, did that in the meantime. Remaining issue is running grails with the "-noreloading" option. That is very inconvenient for development in my case. Any more thoughts? – fluxon Mar 07 '13 at 14:31