- a: author instance
- p1, p2, .... : publish instances
- d1, d2, ... : dispatchers
- lb: load balancer
red arrow is request handler delegation.
Author will only replicate to publish instances. Publish instances may be clustered.
Dispatcher is not used for load balancing, but as a simple cache (reverse proxy).
And, I want to disable auto invalidation of dispatcher cache. And, I want to programmically select a handful of affected dispatcher cache whenever there's update to publish instance.
The main reason for this is because auto-invalidation of dispatcher cache is URL path level based (I can only invalidate cache matching /glob under certain path level).
If your application and repository is laid out with dispatcher in mind, you would not have to programmically calculate dispatcher cache to flush. But, my repository is not structured with HTTP in mind (probably wrong usage of Sling and JCR). So, I need to hand pick dispatcher paths to flush whenever there's an update to publish instance's repository.
Also, my author instance calls Replicator.replicate() in various places (for example, when DAM rendition is modified, author instance automatically replicates the rendition to publish instance).
So, publish instances need to listen to events and when things are changed, it should flush relevant dispatcher cache.
Events to listen can be determined by looking at:
http://localhost:4503/system/console/events
where localhost:4503 is one of publish instances.
I looked at the event logs after activating a page and activating a rendition with On Modification trigger on the flush agent set and unset.
Relevant events are:
(various constants are documented in javadoc: http://dev.day.com/content/docs/en/cq/current/javadoc/constant-values.html )
--8<--
@Component(immediate = true,
enabled = true
)
@Service(value = {EventHandler.class, JobProcessor.class})
@Property(name = EventConstants.EVENT_TOPIC, propertyPrivate = true, value = {
SlingConstants.TOPIC_RESOURCE_CHANGED,//this is for rendition edit
PageEvent.EVENT_TOPIC//this is for page edit
})
public class DispatcherFlushOnPublish implements EventHandler, JobProcessor {
--8<--
No comments:
Post a Comment