Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{style}
   .deflist h4 { margin-top: 0; font-size:100%; font-weight:normal; font-style:italic; color:#888888; }
  .deflist h4 + p { margin-top: 0;  }
  .deflist p { margin-left: 2em; }
  .deflist ul, .deflist ol { margin-left: 2em }
{style}

Overview

Analyzing how we use observation in our Sling-based apps shows a number of recurring patterns, described on this page.

Cached Content

Wiki Markup
{div:class=deflist}
h4. Scenario
In-memory data structures, or "compiled" versions of some content, are created when content changes.
h4. Typical uses
Configurations, CSS/javascript processing, Sling installer, etc.
h4. Trigger
Fine-grained detection of changes in a tree of content, based on paths, path regexps, node types or any other meaningful property.
h4. Action
Clear an internal cache that is rebuilt the next time someone needs it.
h4. Frequency
Content changes are usually not very frequent, for the above typical uses.
h4. Performance requirements
Some latency between content changes and processing is usually not a problem.
h4. Potential issues
N requests coming just after clearing the cache should cause just one cache rebuild, not N.

Code using this pattern for configurations might rather take advantage of OSGi configurations managed by the Sling installer.
h4. Security considerations
Loading content in memory with an admin session will make it available to all users. Loading just the paths of the corresponding content items, and letting users retrieve the content themselves, avoids this problem.
{div}

Content Export, Replication to Remote Systems

Wiki Markup
{div:class=deflist}
h4. Scenario
Content is exported as a file or pushed to a remote system when it changes.
{div}

This is similar to the Cached Content pattern.

Content Ingestion

Wiki Markup
{div:class=deflist}
h4. Scenario
Files that are dropped into the repository are parsed or processed, resulting in content changes and/or workflow events.
h4. Typical uses
Ingesting digital assets, parsing incoming email or other structured files.
h4. Trigger
A file appears in a watched folder.
h4. Action
Process the file, create the corresponding content, move the file to a "processed" or "rejected" folder.
h4. Frequency
Depends on the application.
h4. Performance requirements
Some latency is usually not a problem, but some applications need to process large number of files quickly.
h4. Potential issues
Processing partially saved files too early can be a problem, depending on how files are added to the repository.
h4. Security considerations
Ingestion folders must be properly secured, and incoming content quarantined unless it can be proven safe.
{div}

Content Tree Replication

Wiki Markup
{div:class=deflist}
h4. Scenario
Two or more content trees are kept in sync, usually with customizable mappings and transformations.
h4. Typical uses
Management of federations of websites, which have some common parts and some specific parts.
h4. Trigger
Fine-grained detection of changes in a tree of content, based on paths, path regexps, node types or any other meaningful property.
h4. Action
Replicate the source tree to the target tree(s), optionally applying customizable content transformations.
h4. Frequency
Source events might be quite frequent depending on authoring activity.
h4. Performance requirements
Tree transformations might be costly and usually need to run as background jobs.
h4. Potential issues
An explosion in the number of application-level and repository-level operations is possible depending on the shape of the content tree federation and on the frequency of source content changes.
{div}

Aggregation of changes

Wiki Markup
{div:class=deflist}
h4. Scenario
Collect a number of change events over time and/or for a content subtree, and provide an aggregated view.
h4. Typical uses
Detect and act on changes to digital assets, without reacting to each and every small change.
h4. Trigger
Fine-grained detection of changes in a tree of content, based on paths, path regexps, node types or any other meaningful property.
h4. Action
Store and aggregate events and deliver the results on demand.
h4. Frequency
Might be quite frequent on a busy content tree.
h4. Performance requirements
Aggregating events efficiently, as well as storing them until they're not needed anymore, can impact performance.
h4. Potential issues
Might create a noticeable load on the eventing/observation system, if listening to many detailed events.
h4. Security considerations
Careless aggregation might expose privileged data.
{div}

Consistency Checks and Fixes

Wiki Markup
{div:class=deflist}
h4. Scenario
Watch specific content subtrees for specific changes (nodes moved etc.) and react to them to avoid inconsistencies in the content.
h4. Typical uses
Adapt paths that point to other pieces of content when content moves around.
h4. Trigger
Fine-grained detection of changes in a tree of content, based on paths, path regexps, node types or any other meaningful property.
h4. Action
Modify content to keep it consistent
h4. Frequency
Usually not very frequent as that's mostly meant to handle edge cases.
h4. Performance requirements
A time window during which content can be seen as inconsistent is often unavoidable, keeping that window small is useful.
h4. Potential issues
Content must not be modified by JCR listeners, that should happen asynchronously if using JCR observation.
{div}

Workflow/Job Trigger

Wiki Markup
{div:class=deflist}
h4. Scenario
Trigger workflows and jobs when content changes.
h4. Typical uses
The unix print queue system is a good example, with folders named _incoming_, _printing_, _done_, _rejected_ that store print job definitions.
h4. Trigger
Detection of new content items in the _incoming_ folder(s).
h4. Action
Execute the corresponding tasks and move the job definition nodes according to the results.
h4. Frequency
Depends on the application.
h4. Performance requirements
Depends on the application.
h4. Potential issues
Locking must be used if several job processors are competing for _incoming_ jobs.

Distributed processing of those jobs introduces cluster management requirements.
{div}

Message Queue

Wiki Markup
{div:class=deflist}
h4. Scenario
Implement a simple message queue backed by a content repository subtree.
{div}

This is very similar to the Workflow/Job trigger use case: messages are exchanged between producers and consumers, in the workflow/job trigger case the consumers are job processors.