com.arsdigita.cms.publishToFile
Class QueueManager

java.lang.Object
  extended bycom.arsdigita.cms.publishToFile.QueueManager
All Implemented Interfaces:
Runnable

public class QueueManager
extends Object
implements Runnable

Class for queuing tasks for publishing and unpublishing to the file system and for processing the queue. When processing queued tasks, this class insures that the transaction that created the queue entry is committed before the task is processed. This is mainly for publishing tasks because a http request is used to get the content to publish and the content may not be available until the transaction which makes the content live is committed. The class saves the information for the page to be published using the QueueEntry object (publish_to_fs_queue table). This class locks the Lifecycle thread when it starts processing queue entries.This is done in order to stop the lifecycle thread from modifying the item's date when items are being processed for publication.

Version:
$Revision: #23 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Jeff Teeters (teeters@arsdigita.com), Shashin Shinde, David Lutterkort

Method Summary
static void queueMoveTask(ContentItem liveItem, Folder source, Folder destination)
          Schedule the moving of an item in the file system.
static void queuePublish(ContentItem item)
          Schedule an item for publishing.
static void queueRepublish(ContentItem item)
          Schedule an item for republishing.
static void queueUnpublish(ContentItem item)
          Schedule an item for unpublishing.
static void requeueMissingFiles()
           
 void run()
          Watch queue for entries to process.
static void setBlockSize(Integer size)
          The number of queue entries that should be processed in one block (database transaction).
static void setListener(PublishToFileListener l)
          Set the listener that processes the publish and unpublish requests.
static void setMaximumFailCount(Integer maxFailCount)
          Set how many times processing a queue entry should be attempted at the most.
static void setRetryDelay(Integer delay)
          Set how many seconds the queue manager should wait before trying to process an entry which has previously failed.
static void startWatchingQueue(int startupDelay, int pollDelay)
          Start watching and processing the queue.
static void stopWatchingQueue()
          Stop watching and processing the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setRetryDelay

public static void setRetryDelay(Integer delay)
Set how many seconds the queue manager should wait before trying to process an entry which has previously failed.

Parameters:
delay - number of seconds between reprocessing of failed entries.

setBlockSize

public static void setBlockSize(Integer size)
The number of queue entries that should be processed in one block (database transaction).

Parameters:
size - number of queue enries to be procesed in one block

setMaximumFailCount

public static void setMaximumFailCount(Integer maxFailCount)
Set how many times processing a queue entry should be attempted at the most. Queue entries that have not been processed succesfully after maxFailCount attempts are ignored.

Parameters:
maxFailCount - maximum fail count in publishing thread

setListener

public static void setListener(PublishToFileListener l)
Set the listener that processes the publish and unpublish requests.


requeueMissingFiles

public static void requeueMissingFiles()

queuePublish

public static void queuePublish(ContentItem item)
Schedule an item for publishing. This should be called just after a new live version of an item becomes available.

Parameters:
item - item to be published to file system.

queueUnpublish

public static void queueUnpublish(ContentItem item)
Schedule an item for unpublishing. This should be called just before the live version item is deleted.

Parameters:
item - item to be unpublished from file system.

queueRepublish

public static void queueRepublish(ContentItem item)
Schedule an item for republishing. This should be called whenever an existing live item item should be refreshed in the file system.

Parameters:
item - Item to be republished (unpublished then published) on the file system.

queueMoveTask

public static void queueMoveTask(ContentItem liveItem,
                                 Folder source,
                                 Folder destination)
Schedule the moving of an item in the file system.

Parameters:
liveItem - the item to be moved
source - the folder from which the item is moved
destination - the folder to which the item is moved

startWatchingQueue

public static void startWatchingQueue(int startupDelay,
                                      int pollDelay)
Start watching and processing the queue. This method spawns a background thread that processes the queue. Queue processing starts after startupDelay seconds. The queue is checked for new entries every pollDelay seconds.

Parameters:
startupDelay - number of seconds to wait before starting to process the queue
pollDelay - number of seconds to wait between checks if the queue has any entries.

stopWatchingQueue

public static void stopWatchingQueue()
Stop watching and processing the queue. The background thread that processes the queue will terminate after this method has been called. Termination is not immediate, since the queue may be in the middle of processing a block of entries.


run

public void run()
Watch queue for entries to process. The main routine that starts queue processing.

Specified by:
run in interface Runnable


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 19 2004:2352 UTC