You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/event-hubs/event-hubs-availability-and-consistency.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,42 @@ For use cases that require the maximum up time, this model is preferred.
48
48
## Consistency
49
49
In some scenarios, the ordering of events can be important. For example, you may want your back-end system to process an update command before a delete command. In this instance, you can either set the partition key on an event, or use a `PartitionSender` object (if you are using the old Microsoft.Azure.Messaging library) to only send events to a certain partition. Doing so ensures that when these events are read from the partition, they are read in order. If you are using the **Azure.Messaging.EventHubs** library and for more information, see [Migrating code from PartitionSender to EventHubProducerClient for publishing events to a partition](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/eventhub/Azure.Messaging.EventHubs/MigrationGuide.md#migrating-code-from-partitionsender-to-eventhubproducerclient-for-publishing-events-to-a-partition).
50
50
51
+
#### [Azure.Messaging.EventHubs (5.0.0 or later)](#tab/latest)
52
+
var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>";
53
+
var eventHubName = "<< NAME OF THE EVENT HUB >>";
54
+
55
+
await using (var producerClient = new EventHubProducerClient(connectionString, eventHubName))
56
+
{
57
+
var batchOptions = new CreateBatchOptions() { PartitionId = "my-partition-id" };
58
+
using EventDataBatch eventBatch = await producerClient.CreateBatchAsync(batchOptions);
With this configuration, keep in mind that if the particular partition to which you are sending is unavailable, you will receive an error response. As a point of comparison, if you do not have an affinity to a single partition, the Event Hubs service sends your event to the next available partition.
52
88
53
89
One possible solution to ensure ordering, while also maximizing up time, would be to aggregate events as part of your event processing application. The easiest way to accomplish this is to stamp your event with a custom sequence number property. The following code shows an example:
0 commit comments