org.terracotta.async
Interface ItemProcessor<I>

Type Parameters:
I - the type of item that will be processed
All Known Subinterfaces:
ItemProcessor2<I>

public interface ItemProcessor<I>

Implements the logic that is required to process a certain type of item.

Instances of this class will be used by ProcessingBucket when items are processed one by one. Note that ItemProcessor instances will not be shared across a DSO cluster and are intended to be local on a node. They are tied to an individual processing bucket and the thread that belongs to it. You're thus free to use local resources in an ItemProcessor, like database connections or file handles.

See Also:
ProcessingBucket

Method Summary
 void process(Collection<I> items)
          This method is called from within ProcessingBucket when enqueued items are processed int batch.
 void process(I item)
          This method is called from within ProcessingBucket when enqueued items are processed one by one.
 

Method Detail

process

void process(I item)
             throws ProcessingException
This method is called from within ProcessingBucket when enqueued items are processed one by one.

When this process method finishes, the corresponding item will be definitively removed from the bucket. Note that while the item removal is transactional and your implementation of the process method can be done in a transactional fashion, they are not transactional together. It is thus possible that your ItemProcessor succeeds and that the node goes down before the item is actually removed from the bucket. Your ItemProcessor thus might have to be implemented with some form of bookkeeping that is able to detect that a certain item has already been processed. This can for example be a check on a unique item identifier that is allocated before starting the actual processing of a new item.

Parameters:
item - the item that has to be processed
Throws:
ProcessingException - when an error occurred during processing, the item will not be removed from the bucket and all processing will be interrupted during the current run

process

void process(Collection<I> items)
             throws ProcessingException
This method is called from within ProcessingBucket when enqueued items are processed int batch.

All documentation from the process(Object) method also applies here.

Parameters:
items - the items that have to be processed
Throws:
ProcessingException - when an error occurred during processing, the item will not be removed from the bucket and all processing will be interrupted during the current run


Copyright © 2015 Terracotta, Inc.. All Rights Reserved.