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 cleaner, 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>
<bean id="ticketRegistry" class="org.jasig.cas.ticket.registry.DefaultTicketRegistry" />
<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 two implementations:
- 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 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">
<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.