net.sf.ehcache.constructs.asynchronous
public final class AsynchronousCommandExecutor extends Object
Version: $Id: AsynchronousCommandExecutor.java 191 2006-09-03 22:41:48Z gregluck $
Field Summary | |
---|---|
static int | DEFAULT_DISPATCHER_THREAD_INTERVAL_SECONDS
The dispatcher thread interval. |
static String | MESSAGE_CACHE
The name of the message cache in the ehcache.xml configuration file. |
static int | MINIMUM_SAFE_DISPATCHER_THREAD_INTERVAL
Minimum setting for the dispatcher thread interval.
|
static String | QUEUE_KEY
The messageCache contains Command element values, and a queue that maintains their order.
|
static String | SUCCESSFUL_EXECUTION
The command completed successfully |
Method Summary | |
---|---|
int | countCachedPublishCommands() |
void | dispose()
ehcache also has a shutdown hook, so it will save all to disk.
|
String | generateUniqueIdentifier()
Generates an ID that is guaranteed to be unique for all VM invocations on a machine with a
given IP address.
|
int | getExecuteAttemptsForCommand(String uid)
Gets the number of attempts for the command so far
|
static AsynchronousCommandExecutor | getInstance()
Factory method to get an instance of MessageDispatcher.
|
Ehcache | getMessageCache()
Gets the message cache
|
LinkedList | getQueue()
Must be synchronized as potentially two threads could create new queues at the same time, with the result
that one element would be lost.
|
String | queueForExecution(Command command)
Stores parameters in the MESSAGE_CACHE for later execution. |
void | setDispatcherThreadIntervalSeconds(long dispatcherThreadIntervalSeconds)
Sets the interval between runs of the dispatch thread, when no new dispatch invocations have occurred.
|
void | setUnsafeDispatcherThreadIntervalSeconds(long dispatcherThreadIntervalSeconds)
Sets the interval between runs of the dispatch thread, when no new dispatch invocations have occurred.
|
String | storeCommandToCache(AsynchronousCommandExecutor.InstrumentedCommand instrumentedCommand) |
Returns: the approximate number of PublishCommands stored in the cache
Returns: A String representation of the unique identifier.
Parameters: uid - the unique id for the command returned from queueForExecution
Returns: the number of times the command was executed
Throws: CommandNotFoundInCacheException if the command was not found in the cache. AsynchronousCommandException if their is a problem accessing the cache.
Returns: a fully initialized reference to the singleton.
Throws: AsynchronousCommandException
Returns: the MESSAGE_CACHE cache
Throws: AsynchronousCommandException if the MESSAGE_CACHE is null
Returns: the queue of messages, or if none existed, a new queue
Throws: AsynchronousCommandException
Parameters: command the Command which will be called on to publish the message
Returns: the unique identifier for the command
Throws: AsynchronousCommandException
Parameters: dispatcherThreadIntervalSeconds the time in seconds
Throws: IllegalArgumentException if the argument is less than 30
See Also: for more information.
Parameters: dispatcherThreadIntervalSeconds the time in seconds
See Also: for more information.
Parameters: instrumentedCommand
Returns: A unique id which acts as a handle to the message
Throws: AsynchronousCommandException