-
Notifications
You must be signed in to change notification settings - Fork 21
Eviction
##Eviction
In some use cases, there may be a desire for message processor instances to be transient. For example, in a case where message processors are monitoring events from an individual session with a unique id. Once that session closes the message processor will never be invoked again, but will remain in the container.
For such cases Dempsy provides a means for the message processor to let the container know that it can be evicted from the container. If the message processor annotates a method with the @Evictable annotation that returns a boolean
then the container will periodically invoke that method. If that method ever returns true
, an indication that the message processor instance can be removed from the container, then that message processor will never have the message handler or @Output method invoked again, and will eventually be cleaned up by garbage collection.
You can set the eviction check frequency (which is defaulted to 10 minutes) in the ClusterDefinition using the attributes evictionFrequency
, which is the amount of time between each eviction check, and evictionTimeUnit
which is TimeUnit.SECONDS
by default, but can be set to another unit. The unit, of course, refers to the evictionFrequency
value. An example using Spring follows:
<beans>
...
<bean class="com.nokia.dempsy.config.ApplicationDefinition">
...
<bean class="com.nokia.dempsy.config.ClusterDefinition">
<constructor-arg value="ClusterX"/>
...
<property name="evictionFrequency" value="5"/>
<property name="evictionTimeUnit" value="MINUTES"/>
</bean>
...
Setting the evictionFrequency
on a cluster whose MessageProcessor has nothing annotated with @Evictable has no effect.
Next section: Deployment And Configuration