View on GitHub

Arcus Event Grid

Azure Event Grid development in a breeze

Publishing Events

We provide support for publishing custom events to a custom Azure Event Grid Topics.

Import the following namespace into your project:

using Arcus.EventGrid.Publishing;

Next, create an EventGridPublisher instance via the EventGridPublisherBuilder which requires the endpoint & authentication key of your custom topic endpoint.

var eventGridPublisher = EventGridPublisherBuilder
                                .ForTopic(topicEndpoint)
                                .UsingAuthenticationKey(endpointKey)
                                .Build();

Create your event that you want to publish

string licensePlate = "1-TOM-337";
string eventSubject = $"/cars/{licensePlate}";
string eventId = Guid.NewGuid().ToString();
var @event = new NewCarRegistered(eventId, eventSubject, licensePlate);

await eventGridPublisher.Publish(@event);

Alternatively you can publish a list of events by using

await eventGridPublisher.PublishMany(events);

Resilient Publishing

The EventGridPublisherBuilder also provides several ways to publish events in a resilient manner. Resilient meaning we support three ways to add resilience to your event publishing:

EventGridPublisherBuilder.ForTopic(topicEndpoint)
                         .UsingAuthenticationKey(endpointKey)
                         .WithExponentialRetry(retryCount)
                         .Build();
EventGridPublisherBuilder.ForTopic(topicEndpoint)
                         .UsingAuthenticationKey(endpointKey)
                         .WithCircuitBreaker(exceptionsBeforeBreaking, durationOfBreak)
                         .Build();
EventGridPublisherBuilder.ForTopic(topicEndpoint)
                         .UsingAuthenticationKey(endpointKey)
                         .WithExponentialRetry(retryCount)
                         .WithCircuitBreaker(exceptionsBeforeBreaking, durationOfBreak)
                         .Build();

← back