Created
December 4, 2019 08:28
-
-
Save ceilingfish/7fd6e07bf1bb0acec184c191f2f1ddb7 to your computer and use it in GitHub Desktop.
Rewinding azure event hub offsets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async Task Main() | |
| { | |
| var connectionString = "Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=ReadEvents;SharedAccessKey=MySecretKey;EntityPath=hub"; | |
| Console.WriteLine("Rewinding event hub..."); | |
| var eventProcessorHost = new EventProcessorHost( | |
| "reporting", | |
| PartitionReceiver.DefaultConsumerGroupName, | |
| connectionString, | |
| "UseDevelopmentStorage=true", | |
| "azure-webjobs-eventhub"); | |
| EventProcessorOptions options = new EventProcessorOptions() | |
| { | |
| InitialOffsetProvider = (partitionId) => EventPosition.FromEnqueuedTime(new DateTime(2019,12, 3,0,0,0)) | |
| }; | |
| await eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>(options); | |
| await eventProcessorHost.UnregisterEventProcessorAsync(); | |
| } | |
| public class SimpleEventProcessor : IEventProcessor | |
| { | |
| public Task CloseAsync(PartitionContext context, CloseReason reason) => Task.CompletedTask; | |
| public Task OpenAsync(PartitionContext context) => Task.CompletedTask; | |
| public Task ProcessErrorAsync(PartitionContext context, Exception error) => Task.CompletedTask; | |
| public Task ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> messages) => Task.CompletedTask; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment