|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.netflix.curator.framework.recipes.queue.QueueBuilder<T>
T - item type for the queuepublic class QueueBuilder<T>
The builder for both DistributedQueue and DistributedPriorityQueue
| Method Summary | ||
|---|---|---|
static
|
builder(CuratorFramework client,
QueueConsumer<T> consumer,
QueueSerializer<T> serializer,
String queuePath)
Allocate a new builder |
|
DistributedPriorityQueue<T> |
buildPriorityQueue(int minItemsBeforeRefresh)
Build a DistributedPriorityQueue from the current builder values. |
|
DistributedQueue<T> |
buildQueue()
Build a DistributedQueue from the current builder values |
|
QueueBuilder<T> |
executor(Executor executor)
Change the executor used. |
|
QueueBuilder<T> |
lockPath(String path)
Without a lock set, queue items are removed before being sent to the queue consumer. |
|
QueueBuilder<T> |
threadFactory(ThreadFactory factory)
Change the thread factory used. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> QueueBuilder<T> builder(CuratorFramework client,
QueueConsumer<T> consumer,
QueueSerializer<T> serializer,
String queuePath)
client - the curator clientconsumer - functor to consume messages - NOTE: pass null to make this a producer-only queueserializer - serializer to use for itemsqueuePath - path to store queue
public DistributedQueue<T> buildQueue()
DistributedQueue from the current builder values
public DistributedPriorityQueue<T> buildPriorityQueue(int minItemsBeforeRefresh)
Build a DistributedPriorityQueue from the current builder values.
When the priority
queue detects an item addition/removal, it will stop processing its current list of items and
refresh the list. minItemsBeforeRefresh modifies this. It determines the minimum
number of items from the active list that will get processed before a refresh.
Due to a quirk in the way ZooKeeper notifies changes, the queue will get an item addition/remove
notification after every item is processed. This can lead to poor performance. Set
minItemsBeforeRefresh to the value your application can tolerate being out of sync.
For example: if the queue sees 10 items to process, it will end up making 10 calls to ZooKeeper
to check status. You can control this by setting minItemsBeforeRefresh to 10 (or more)
and the queue will only refresh with ZooKeeper after 10 items are processed
minItemsBeforeRefresh - minimum items to process before refreshing the item list
public QueueBuilder<T> threadFactory(ThreadFactory factory)
Executors.defaultThreadFactory()
factory - new thread factory to use
public QueueBuilder<T> executor(Executor executor)
MoreExecutors.sameThreadExecutor()
executor - new executor to use
public QueueBuilder<T> lockPath(String path)
Without a lock set, queue items are removed before being sent to the queue consumer. This can result in message loss if the consumer fails to complete the message or the process dies.
Use a lock to make the message recoverable. A lock is held while the message is being processed - this prevents other processes from taking the message. The message will not be removed from the queue until the consumer functor returns. Thus, if there is a failure or the process dies, the message will get sent to another process. There is a small performance penalty for this behavior however.
path - path for the lock
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||