Beispiel #1
0
        private async Task Connect()
        {
            _connection = _connectionProvider.GetConnection();
            await _connection.ConnectAsync();

            var streamId = _streamId == null ? $"$ce-{_aggregateType.ToUpper()}" : _streamId.Id;
            //Check if this subscription already exists
            await _connection.CreateSubscription(streamId,
                                                 _subscriptionName,
                                                 await _connectionProvider.GetCredentials(),
                                                 _logger);


            Func <EventStorePersistentSubscriptionBase, ResolvedEvent, int?, Task> processEvent = (subscriptionBase, resolvedEvent, c) => {
                return(HandleEvent(subscriptionBase, resolvedEvent));
            };

            _subscriptionBase = await _connection.ConnectToPersistentSubscriptionAsync(
                streamId,
                _subscriptionName,
                processEvent,
                bufferSize : 10,
                subscriptionDropped : SubscriptionDropped,
                autoAck : false);

            _connected = true;
            _status    = SubscriptionConnectionStatus.Connected;
        }