Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

The JBossCacheStore allow allows JCaptcha to be used in a clustered environment. It allows storing , generated captchas are stored in a distributed Cache. So a A user can now retrieve a captcha from a node and validate it on another node.

This tutorial shows how to set up the JCaptcha extension and configure JBossCache 2

...

Code Block
<dependency>
	<groupId>com.octo.captcha</groupId>    
	<artifactId>jcaptcha-extension-jbosscache-store</artifactId>
	<version>1.0-SNAPSHOT</version>
</dependency>

...

The three last arguments are related to the JCaptcha garbage collector. They must be set carefully in order to avoid overhead with JBossCache eviction policy. See next the last section QQQ for more explanations.

Configure the JBoss Cache

...

This can be done by adding the jcaptcha.jbosscache.config system property to the JVM.

Add the following argument to the JVM command line or in the JAVA_OPTS environment variable.

Code Block

-Djcaptcha.jbosscache.config=myCaptchaStoreJBossCacheConfig.xml

Modify the XML configuration file

This configuration is a proposal and has to be adapted to your project requirements. Please refers to the JBossCache reference documentation for further details (http://labs.jboss.org/portal/jbosscache/docs/index.html).

You could find a sample here (extension-jbosscache-store\src\test\resources)

...

Code Block
<attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>

Add the captcharegion configuration in the EvictionPolicyConfig XML node

Code Block

     
 <region name="/captcha">
         <attribute name="maxNodes">5000</attribute>
         <attribute name="timeToLiveSeconds">0</attribute>
         <attribute name="maxAgeSeconds">120</attribute>
       </region>

...

  • Disable JCaptcha garbage collector
    • JCaptcha maxCaptchaStoreSize must be set to zero
    • JCaptcha minGuarantedStorageDelayInSeconds must be set to zero
    • JCaptcha captchaStoreLoadBeforeGarbageCollection must be bigger than JBossCache maxNodes
  • Disable captchas TimeToLive
    • JBossCache timeToLiveSeconds must be set to zero
  • Configure resolution max time (usually two minutes)
    • JBossCache maxAgeSeconds must be less than ten minutes
  • Manage the CaptchaStore memory size
    • JBossCache maxNodes must be set in relation to the JVM memory size parameter (ex : -Xmx256m)

Deployment scheme

Please refers to the JGroups reference documentation for detailed explanations.
http://www.jgroups.org/javagroupsnew/docs/tutorial/html_single/index.html