CatchupSubscription question

I create a CatchupSubscription, and implement the EventAppeared.
I add some logging in indicating when an Event appears, and as exepcetd they appear sequentially, one after another.
If I add an awaitable call in the eventhandler, the behaviour changes. As soon as it hits the await, more events appears start apeparing while the current event is being awaited on.

Is this expected, and perhaps my understand of the process is the problem?

Small code example:

String connectionString = “ConnectTo=tcp://admin:[email protected]:1113;VerboseLogging=true;”;

var eventStoreConnection = EventStoreConnection.Create(connectionString);
await eventStoreConnection.ConnectAsync();

String streamname = @"$et-myEvents";

var r = eventStoreConnection.SubscribeToStreamFrom(streamname, 0,
CatchUpSubscriptionSettings.Default,
async (subscription,
@event) =>
{
var request = BuildHttpRequestMessage(@event.OriginalEvent.Data);

var httpClient = GetHttpClient();

//When this code is hit, the next Event Appears!
await httpClient.SendAsync(request, CancellationToken.None);
});

Any ideas?

Could you elaborate on “more events start appearing”? Appearing where?

Alexey,

In the EventAppeared method I setup SubscribeToStreamFrom.
If I log out the event number in this Func, I can see event appears in the expected, 1 at a time.
As soon as I introduced this async call, and invoke, execution immediately switches to EventAppeared with a new event (while my first event is still doing it’s thing) and this continues on (we only noticed this was happening because our database was getting hammered)

Does that make it clearer?

I never experienced anything that could indicate that events appear in the subscription before the previous event is processed.

I remember that some older client version had a synchronous subscription delegate signature. In that case, it won’t handle asynchronous event handler correctly since it won’t wait when the handler finished execution since it doesn’t await the task.

I composed a sample with v5.0.8 client and it works just fine. All events are processed in sequence.

Alexey,

Thanks for taking the time on this.
I took a copy of your repo and tried it out locally, and as you said, no problem.
I grafted my original code in, and again no problems.

Even with my own code, in a standalone project, I can no longer replicate this problem.

I can only suspect that you were using an older client where the delegate signature was Action<EventStoreCatchUpSubscription, ResolvedEvent>, which is now Func<EventStoreCatchUpSubscription, ResolvedEvent, Task>

Alexey,

Suspect you are correct.
Thanks again.