TicketRegistry Cleaner
New CAS documentation site
CAS documentation has moved over to apereo.github.io/cas, starting with CAS version 4.x. The wiki will no longer be maintained. For the most recent version of the documentation, please refer to the aforementioned link.
As of 3.4, the Default Ticket Registry Cleaner has been enhanced to support high-availability environments.
When do I need to use a Ticket Registry Cleaner?
The ticket registry cleaner should be used for ticket registries that cannot manage their own state. That would include the default in-memory registry, the JPA-backed registry (unless you are executing manual SQL statements), etc. The Memcache-backed registry does not require a registry cleaner.
What do I need to configure?
If you're using the default Default Ticket Registry configuration, your WEB-INF/spring-configuration/ticketRegistry.xml probably looks like this:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <description> Configuration for the default TicketRegistry which stores the tickets in-memory and cleans them out as specified intervals. </description> <!-- Ticket Registry --> <bean id="ticketRegistry" class="org.jasig.cas.ticket.registry.DefaultTicketRegistry" /> <!--Quartz --> <!-- TICKET REGISTRY CLEANER --> <bean id="ticketRegistryCleaner" class="org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner" p:ticketRegistry-ref="ticketRegistry" /> <bean id="jobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" p:targetObject-ref="ticketRegistryCleaner" p:targetMethod="clean" /> <bean id="triggerJobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.SimpleTriggerBean" p:jobDetail-ref="jobDetailTicketRegistryCleaner" p:startDelay="20000" p:repeatInterval="5000000" /> </beans>
You do not need to modify this at all.
But if I'm not using the default memory storage mechanism?
Since 3.4, we've introduced a new interface that integrates with the RegistryCleaner. Its called LockingStrategy (org.jasig.cas.ticket.registry.support.LockingStrategy). It comes with several implementations:
- JpaLockingStrategy (since 3.4.11)
- NoOpLockingStrategy
- JdbcLockingStrategy
NoOpLockingStrategy is what is automatically configured in the above example (if you don't specify anything). If you're using the JPA-backed registry, you should expect to have to configure the JpaLockingStrategy (>= 3.4.11) or JdbcLockingStrategy (3.4.11).
For CAS >= 3.4.11 example JpaTicketRegistry configuration including the JpaLockingStrategy, see JpaTicketRegistry.
Example configuration using the JdbcLockingStrategy:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!-- Ticket Registry --> <!-- configure the ticket registry here. Most likely copied from JPA page. Its not copied in here so that we don't have to worry about keeping two pages in sync. --> <!--Quartz --> <!-- TICKET REGISTRY CLEANER --> <bean id="ticketRegistryCleaner" class="org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner" p:ticketRegistry-ref="ticketRegistry"> <property name="lock"> <bean class="org.jasig.cas.ticket.registry.support.JdbcLockingStrategy" p:uniqueId="my_unique_machine" p:applicationId="cas" p:dataSource-ref"dataSource" /> </property> </bean> <bean id="jobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" p:targetObject-ref="ticketRegistryCleaner" p:targetMethod="clean" /> <bean id="triggerJobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.SimpleTriggerBean" p:jobDetail-ref="jobDetailTicketRegistryCleaner" p:startDelay="20000" p:repeatInterval="5000000" /> </beans>
This will configure the cleaner with the following defaults:
- tableName = "LOCKS"
- uniqueIdColumnName = "UNIQUE_ID"
- applicationIdColumnName = "APPLICATION_ID"
- expirationDataColumnName = "EXPIRATION_DATE"
- platform = SQL92
- lockTimeout = 3600 [1 hour]
You can override any of these properties. See the JavaDoc for more information.
If you're using other backing mechanisms, you would need to write an appropriate LockingStrategy and configure it similar to above.