Package org.hobbit.core.rabbit
Class DataReceiverImpl.Builder
- java.lang.Object
-
- org.hobbit.core.rabbit.DataReceiverImpl.Builder
-
- Enclosing class:
- DataReceiverImpl
public static class DataReceiverImpl.Builder extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringDATA_HANDLER_MISSING_ERRORprotected DataHandlerdataHandlerprotected RabbitQueueFactoryfactoryprotected intmaxParallelProcessedMsgsprotected RabbitQueuequeueprotected static StringQUEUE_INFO_MISSING_ERRORprotected StringqueueName
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataReceiverImplbuild()Builds theDataReceiverImplinstance with the previously given information.DataReceiverImpl.BuilderdataHandler(DataHandler dataHandler)Sets the handler that is called if data is incoming.DataReceiverImpl.BuildermaxParallelProcessedMsgs(int maxParallelProcessedMsgs)Sets the maximum number of incoming messages that are processed in parallel.DataReceiverImpl.Builderqueue(RabbitQueue queue)Sets the queue that is used to receive data.DataReceiverImpl.Builderqueue(RabbitQueueFactory factory, String queueName)Method for providing the necessary information to create a queue if it has not been provided with thequeue(RabbitQueue)method.
-
-
-
Field Detail
-
QUEUE_INFO_MISSING_ERROR
protected static final String QUEUE_INFO_MISSING_ERROR
- See Also:
- Constant Field Values
-
DATA_HANDLER_MISSING_ERROR
protected static final String DATA_HANDLER_MISSING_ERROR
- See Also:
- Constant Field Values
-
dataHandler
protected DataHandler dataHandler
-
queue
protected RabbitQueue queue
-
queueName
protected String queueName
-
maxParallelProcessedMsgs
protected int maxParallelProcessedMsgs
-
factory
protected RabbitQueueFactory factory
-
-
Method Detail
-
dataHandler
public DataReceiverImpl.Builder dataHandler(DataHandler dataHandler)
Sets the handler that is called if data is incoming.- Parameters:
dataHandler- the handler that is called if data is incoming- Returns:
- this builder instance
-
queue
public DataReceiverImpl.Builder queue(RabbitQueue queue)
Sets the queue that is used to receive data.- Parameters:
queue- the queue that is used to receive data- Returns:
- this builder instance
-
queue
public DataReceiverImpl.Builder queue(RabbitQueueFactory factory, String queueName)
Method for providing the necessary information to create a queue if it has not been provided with thequeue(RabbitQueue)method. Note that this information is not used if a queue has been provided.- Parameters:
factory- the queue factory used to create a queuequeueName- the name of the newly created queue- Returns:
- this builder instance
-
maxParallelProcessedMsgs
public DataReceiverImpl.Builder maxParallelProcessedMsgs(int maxParallelProcessedMsgs)
Sets the maximum number of incoming messages that are processed in parallel. Additional messages have to wait in the queue.- Parameters:
maxParallelProcessedMsgs- the maximum number of incoming messages that are processed in parallel- Returns:
- this builder instance
-
build
public DataReceiverImpl build() throws IllegalStateException, IOException
Builds theDataReceiverImplinstance with the previously given information.- Returns:
- The newly created DataReceiver instance
- Throws:
IllegalStateException- if the dataHandler is missing or if neither a queue nor the information needed to create a queue have been provided.IOException- if an exception is thrown while creating a new queue or if the given queue can not be configured by the newly created DataReceiver. Note that in the latter case the queue will be closed.
-
-