I am wanting to read a specific message from an EventHub.
I'm using the EventHubConsumerClient and the ReadEventsFromPartitionAsync using a partitionId, and Offset I have.
client.ReadEventsFromPartitionAsync(partitionId, EventPosition.FromOffset(offset), cancellationSource.Token);
The issue I have is, that despite the Offset and Partition ID being correct, I'm not getting the messages I expect back.
Context
I working on something to validate that messages are being properly processed in a distributed system.
Source Event Hub -> Processor Function -> Destination Event Hubs.
I read both ends (hubs) and validate messages arrive where they should, if they don't, look up the message from the Source Event Hub, (by partitionId and offset matching against a message ID).
It is the messages I'm looking up that don't appear to have message IDs or offset IDs I expect.
CodePudding user response:
UPDATE:
I was mistaken in my recall of the defaults for EventPosition and referenced docs for the wrong SDK package below. By default, EventPosition.FromOffset is inclusive. (src)
The creation pattern in the question would include the event at the provided offset. If you're not seeing the event returned, then the offset would seem to be incorrect.
Original Answer (incorrect):
The EventPosition that you're building is non-inclusive and will not include the event at that offset, but rather start at the next available event. Using the following overload should target the event that you're looking for:
EventPosition.FromOffset(offset, true)
It looks as if the summary in the docs doesn't do a great job of calling attention to the default; I'll take a follow-up to make that more clear.
CodePudding user response:
The issue was due to the incorrect offsets being provided from the AZ Function binding metadata.
Using a batch of one - correct.
Using a batch of more than one, completely wrong offsets, sequences etc.
Updated the eventhubs package (preview..) and it works fine :/
