ReceiverOptions Class

  • java.lang.Object
    • com.microsoft.azure.eventhubs.ReceiverOptions

public final class ReceiverOptions

Represents various optional behaviors which can be turned on or off during the creation of a PartitionReceiver.

Constructor Summary

Constructor Description
ReceiverOptions()

Method Summary

Modifier and Type Method and Description
String getIdentifier()

Gets the identifier of the PartitionReceiver

int getPrefetchCount()

Get Prefetch Count.

boolean getReceiverRuntimeMetricEnabled()

Knob to enable/disable runtime metric of the receiver.

void setIdentifier(String value)

Set an identifier to PartitionReceiver.

void setPrefetchCount(int prefetchCount)

Set the number of events that can be pre-fetched and cached at the PartitionReceiver.

void setReceiverRuntimeMetricEnabled(boolean value)

Knob to enable/disable runtime metric of the receiver.

Methods inherited from java.lang.Object

Constructor Details

ReceiverOptions

public ReceiverOptions()

Method Details

getIdentifier

public String getIdentifier()

Gets the identifier of the PartitionReceiver

Returns:

identifier of the PartitionReceiver; null if nothing was set

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.

getReceiverRuntimeMetricEnabled

public boolean getReceiverRuntimeMetricEnabled()

Knob to enable/disable runtime metric of the receiver. If this is set to true and is passed to EventHubClient#createReceiver, after the first receive(int maxEventCount) call, getRuntimeInformation() is populated.

Enabling this knob will add 3 additional properties to all EventData's received on the EventHubClient#createReceiver.

Returns:

the boolean indicating, whether, the runtime metric of the receiver was enabled

setIdentifier

public void setIdentifier(String value)

Set an identifier to PartitionReceiver.

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 of PartitionReceiver.

Parameters:

value - string to identify PartitionReceiver

setPrefetchCount

public void setPrefetchCount(int prefetchCount)

Set the number of events that can be pre-fetched and cached at the PartitionReceiver.

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

setReceiverRuntimeMetricEnabled

public void setReceiverRuntimeMetricEnabled(boolean value)

Knob to enable/disable runtime metric of the receiver. If this is set to true and is passed to EventHubClient#createReceiver, after the first receive(int maxEventCount) call, getRuntimeInformation() and 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 getPartitionRuntimeInformation(String partitionId) call to Event Hubs service. To achieve this, behind the scenes, along with the actual EventData, that the Event Hubs PartitionReceiver 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 each EventData received by the client.

Parameters:

value - the boolean to indicate, whether, the runtime metric of the receiver should be enabled

Applies to