Class EventProcessorOptions
- java.lang.Object
-
- com.microsoft.azure.eventprocessorhost.EventProcessorOptions
-
public final class EventProcessorOptions extends Object
Options affecting the behavior of the event processor host instance in general.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
EventProcessorOptions.EndOfStreamInitialPositionProvider
A prefab initial position provider that starts from the next event that becomes available.class
EventProcessorOptions.StartOfStreamInitialPositionProvider
A prefab initial position provider that starts from the first event available.
-
Constructor Summary
Constructors Constructor Description EventProcessorOptions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EventProcessorOptions
getDefaultOptions()
Returns an EventProcessorOptions instance with all options set to the default values.Function<String,EventPosition>
getInitialPositionProvider()
If there is no checkpoint for a partition, the initialPositionProvider function is used to determine the position at which to start receiving events for that partition.Boolean
getInvokeProcessorAfterReceiveTimeout()
Returns whether the EventProcessorHost will call IEventProcessor.onEvents() with an empty iterable when a receive timeout occurs (true) or not (false).int
getMaxBatchSize()
Returns the maximum number of events that will be passed to one call to IEventProcessor.onEventsint
getPrefetchCount()
Returns the current prefetch count for the underlying event hub client.boolean
getReceiverRuntimeMetricEnabled()
Knob to enable/disable runtime metric of the receiver.Duration
getReceiveTimeOut()
Returns the timeout for receive operations.void
setExceptionNotification(Consumer<ExceptionReceivedEventArgs> notificationHandler)
Sets a handler which receives notification of general exceptions.void
setInitialPositionProvider(Function<String,EventPosition> initialPositionProvider)
Sets the function used to determine the position at which to start receiving events for a partition if there is no checkpoint for that partition.void
setInvokeProcessorAfterReceiveTimeout(Boolean invokeProcessorAfterReceiveTimeout)
Changes whether the EventProcessorHost will call IEventProcessor.onEvents() with an empty iterable when a receive timeout occurs (true) or not (false).void
setMaxBatchSize(int maxBatchSize)
Sets the maximum number of events that will be passed to one call to IEventProcessor.onEventsvoid
setPrefetchCount(int prefetchCount)
Sets the prefetch count for the underlying event hub client.void
setReceiverRuntimeMetricEnabled(boolean value)
Knob to enable/disable runtime metric of the receiver.void
setReceiveTimeOut(Duration receiveTimeOut)
Sets the timeout for receive operations.
-
-
-
Method Detail
-
getDefaultOptions
public static EventProcessorOptions getDefaultOptions()
Returns an EventProcessorOptions instance with all options set to the default values. The default values are:MaxBatchSize: 10 ReceiveTimeOut: 1 minute PrefetchCount: 300 InitialPositionProvider: uses the last checkpoint, or START_OF_STREAM InvokeProcessorAfterReceiveTimeout: false ReceiverRuntimeMetricEnabled: false
- Returns:
- an EventProcessorOptions instance with all options set to the default values
-
setExceptionNotification
public void setExceptionNotification(Consumer<ExceptionReceivedEventArgs> notificationHandler)
Sets a handler which receives notification of general exceptions.Exceptions which occur while processing events from a particular Event Hub partition are delivered to the onError method of the event processor for that partition. This handler is called on occasions when there is no event processor associated with the throwing activity, or the event processor could not be created.
The handler is not expected to do anything about the exception. If it is possible to recover, the event processor host instance will recover automatically.
- Parameters:
notificationHandler
- Handler which is called when an exception occurs. Set to null to stop handling.
-
getMaxBatchSize
public int getMaxBatchSize()
Returns the maximum number of events that will be passed to one call to IEventProcessor.onEvents- Returns:
- the maximum maximum number of events that will be passed to one call to IEventProcessor.onEvents
-
setMaxBatchSize
public void setMaxBatchSize(int maxBatchSize)
Sets the maximum number of events that will be passed to one call to IEventProcessor.onEvents- Parameters:
maxBatchSize
- the maximum number of events that will be passed to one call to IEventProcessor.onEvents
-
getReceiveTimeOut
public Duration getReceiveTimeOut()
Returns the timeout for receive operations.- Returns:
- the timeout for receive operations
-
setReceiveTimeOut
public void setReceiveTimeOut(Duration receiveTimeOut)
Sets the timeout for receive operations.- Parameters:
receiveTimeOut
- new timeout for receive operations
-
getPrefetchCount
public int getPrefetchCount()
Returns the current prefetch count for the underlying event hub client.- Returns:
- the current prefetch count for the underlying client
-
setPrefetchCount
public void setPrefetchCount(int prefetchCount)
Sets the prefetch count for the underlying event hub client. The default is 300. This controls how many events are received in advance.- Parameters:
prefetchCount
- The new prefetch count.
-
getInitialPositionProvider
public Function<String,EventPosition> getInitialPositionProvider()
If there is no checkpoint for a partition, the initialPositionProvider function is used to determine the position at which to start receiving events for that partition.- Returns:
- the current initial position provider function
-
setInitialPositionProvider
public void setInitialPositionProvider(Function<String,EventPosition> initialPositionProvider)
Sets the function used to determine the position at which to start receiving events for a partition if there is no checkpoint for that partition. The provider function takes one argument, the partition id (a String), and returns the desired position.- Parameters:
initialPositionProvider
- The new provider function.
-
getInvokeProcessorAfterReceiveTimeout
public Boolean getInvokeProcessorAfterReceiveTimeout()
Returns whether the EventProcessorHost will call IEventProcessor.onEvents() with an empty iterable when a receive timeout occurs (true) or not (false). Defaults to false.- Returns:
- true if EventProcessorHost will call IEventProcessor.OnEvents on receive timeout, false otherwise
-
setInvokeProcessorAfterReceiveTimeout
public void setInvokeProcessorAfterReceiveTimeout(Boolean invokeProcessorAfterReceiveTimeout)
Changes whether the EventProcessorHost will call IEventProcessor.onEvents() with an empty iterable when a receive timeout occurs (true) or not (false).The default is false (no call).
- Parameters:
invokeProcessorAfterReceiveTimeout
- the new value for what to do
-
getReceiverRuntimeMetricEnabled
public boolean getReceiverRuntimeMetricEnabled()
Knob to enable/disable runtime metric of the receiver. If this is set to true, the first parameterPartitionContext.runtimeInformation
ofIEventProcessor.onEvents(com.microsoft.azure.eventprocessorhost.PartitionContext, java.lang.Iterable)
will be populated.Enabling this knob will add 3 additional properties to all raw AMQP events received.
- Returns:
- the
boolean
indicating, whether, the runtime metric of the receiver was enabled
-
setReceiverRuntimeMetricEnabled
public void setReceiverRuntimeMetricEnabled(boolean value)
Knob to enable/disable runtime metric of the receiver. If this is set to true, the first parameterPartitionContext.runtimeInformation
ofIEventProcessor.onEvents(com.microsoft.azure.eventprocessorhost.PartitionContext, java.lang.Iterable)
will be populated.Enabling this knob will add 3 additional properties to all raw AMQP events received.
- Parameters:
value
- theboolean
to indicate, whether, the runtime metric of the receiver should be enabled
-
-