PartitionReceiver.ReceiveAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ReceiveAsync(Int32) |
Receive a batch of EventData's from an EventHub partition |
ReceiveAsync(Int32, TimeSpan) |
Receive a batch of EventData's from an EventHub partition by allowing wait time on each individual call. |
ReceiveAsync(Int32)
- Source:
- PartitionReceiver.cs
Receive a batch of EventData's from an EventHub partition
public System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Azure.EventHubs.EventData>> ReceiveAsync (int maxMessageCount);
member this.ReceiveAsync : int -> System.Threading.Tasks.Task<seq<Microsoft.Azure.EventHubs.EventData>>
Public Function ReceiveAsync (maxMessageCount As Integer) As Task(Of IEnumerable(Of EventData))
Parameters
- maxMessageCount
- Int32
Returns
A Task that will yield a batch of EventData from the partition on which this receiver is created. Returns 'null' if no EventData is present.
Examples
Sample code:
EventHubClient client = EventHubClient.Create("__connectionString__");
PartitionReceiver receiver = client.CreateReceiver("ConsumerGroup1", "1");
IEnumerable<EventData> receivedEvents = await receiver.ReceiveAsync(BatchSize);
while (true)
{
int batchSize = 0;
if (receivedEvents != null)
{
foreach (EventData receivedEvent in receivedEvents)
{
Console.WriteLine("Message Payload: {0}", Encoding.UTF8.GetString(receivedEvent.Body));
Console.WriteLine("Offset: {0}, SeqNo: {1}, EnqueueTime: {2}",
receivedEvent.SystemProperties.Offset,
receivedEvent.SystemProperties.SequenceNumber,
receivedEvent.SystemProperties.EnqueuedTime);
batchSize++;
}
}
Console.WriteLine("ReceivedBatch Size: {0}", batchSize);
receivedEvents = await receiver.ReceiveAsync();
}
Applies to
ReceiveAsync(Int32, TimeSpan)
- Source:
- PartitionReceiver.cs
Receive a batch of EventData's from an EventHub partition by allowing wait time on each individual call.
public System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Azure.EventHubs.EventData>> ReceiveAsync (int maxMessageCount, TimeSpan waitTime);
member this.ReceiveAsync : int * TimeSpan -> System.Threading.Tasks.Task<seq<Microsoft.Azure.EventHubs.EventData>>
Public Function ReceiveAsync (maxMessageCount As Integer, waitTime As TimeSpan) As Task(Of IEnumerable(Of EventData))
Parameters
- maxMessageCount
- Int32
- waitTime
- TimeSpan
Returns
A Task that will yield a batch of EventData from the partition on which this receiver is created. Returns 'null' if no EventData is present.
Applies to
Azure SDK for .NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기