Class ReceiverOptions
- java.lang.Object
-
- com.microsoft.azure.eventhubs.ReceiverOptions
-
public final class ReceiverOptions extends Object
Represents various optional behaviors which can be turned on or off during the creation of aPartitionReceiver
.
-
-
Constructor Summary
Constructors Constructor Description ReceiverOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getIdentifier()
Gets the identifier of thePartitionReceiver
int
getPrefetchCount()
Get Prefetch Count.boolean
getReceiverRuntimeMetricEnabled()
Knob to enable/disable runtime metric of the receiver.void
setIdentifier(String value)
Set an identifier toPartitionReceiver
.void
setPrefetchCount(int prefetchCount)
Set the number of events that can be pre-fetched and cached at thePartitionReceiver
.void
setReceiverRuntimeMetricEnabled(boolean value)
Knob to enable/disable runtime metric of the receiver.
-
-
-
Method Detail
-
getReceiverRuntimeMetricEnabled
public boolean getReceiverRuntimeMetricEnabled()
Knob to enable/disable runtime metric of the receiver. If this is set to true and is passed toEventHubClient.createReceiver(java.lang.String, java.lang.String, com.microsoft.azure.eventhubs.EventPosition)
, after the firstPartitionReceiver.receive(int)
call,PartitionReceiver.getRuntimeInformation()
is populated.Enabling this knob will add 3 additional properties to all
EventData
's received on theEventHubClient.createReceiver(java.lang.String, java.lang.String, com.microsoft.azure.eventhubs.EventPosition)
.- 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 and is passed toEventHubClient.createReceiver(java.lang.String, java.lang.String, com.microsoft.azure.eventhubs.EventPosition)
, after the firstPartitionReceiver.receive(int)
call,PartitionReceiver.getRuntimeInformation()
andPartitionReceiver.getEventPosition()
will be populated.This knob facilitates for an optimization where the Consumer of Event Hub has the end of stream details at the disposal, without making any additional
EventHubClient.getPartitionRuntimeInformation(String)
call to Event Hubs service. To achieve this, behind the scenes, along with the actualEventData
, that the Event HubsPartitionReceiver
delivers, it includes extra information about the Event Hubs partitions end of stream details on every event. In summary, enabling this knob will help users to save an extra call to Event Hubs service to fetch Event Hubs partition information and as a result, will add that information as header to eachEventData
received by the client.- Parameters:
value
- theboolean
to indicate, whether, the runtime metric of the receiver should be enabled
-
getIdentifier
public String getIdentifier()
Gets the identifier of thePartitionReceiver
- Returns:
- identifier of the
PartitionReceiver
; null if nothing was set
-
setIdentifier
public void setIdentifier(String value)
Set an identifier toPartitionReceiver
.This identifier will be used by EventHubs service when reporting any errors across receivers, and is caused by this receiver. For example, when receiver quota limit is hit, while a user is trying to create New receiver, EventHubs service will throw
QuotaExceededException
and will include this identifier. So, its very critical to choose a value, which can uniquely identify the whereabouts ofPartitionReceiver
.- Parameters:
value
- string to identifyPartitionReceiver
-
getPrefetchCount
public int getPrefetchCount()
Get Prefetch Count.- Returns:
- the upper limit of events this receiver will actively receive regardless of whether a receive operation is pending.
- See Also:
setPrefetchCount(int)
-
setPrefetchCount
public void setPrefetchCount(int prefetchCount) throws EventHubException
Set the number of events that can be pre-fetched and cached at thePartitionReceiver
.By default the value is 500
- Parameters:
prefetchCount
- the number of events to pre-fetch. value must be between 1 and 2000.- Throws:
EventHubException
- if setting prefetchCount encounters error
-
-