private static async Task <ISet <PubSubSubscriptionState> > PubsubRegisterProducer(IStreamPubSub pubSub, StreamId streamId, string streamProviderName,
                                                                                           IStreamProducerExtension meAsStreamProducer, ILogger logger)
        {
            try
            {
                var streamData = await pubSub.RegisterProducer(streamId, streamProviderName, meAsStreamProducer);

                return(streamData);
            }
            catch (Exception e)
            {
                logger.Error(ErrorCode.PersistentStreamPullingAgent_17, $"RegisterAsStreamProducer failed due to {e}", e);
                throw e;
            }
        }
        private static async Task <ISet <PubSubSubscriptionState> > PubsubRegisterProducer(IStreamPubSub pubSub, InternalStreamId streamId,
                                                                                           IStreamProducerExtension meAsStreamProducer, ILogger logger)
        {
            try
            {
                var streamData = await pubSub.RegisterProducer(streamId, meAsStreamProducer);

                return(streamData);
            }
            catch (Exception e)
            {
                logger.LogError((int)ErrorCode.PersistentStreamPullingAgent_17, e, "RegisterAsStreamProducer failed");
                throw;
            }
        }
Example #3
0
        async Task <ISet <PubSubSubscriptionState> > IStreamPubSub.RegisterProducer(StreamId streamId, string streamProvider, IStreamProducerExtension streamProducer)
        {
            var matches = new PubSubSubscriptionState[0];

            if (ShouldMatch(streamProvider))
            {
                matches = (from StreamPubSubMatch m in matcher(new StreamIdentity(streamId))
                           let subId = GuidId.GetNewGuidId()
                                       select new PubSubSubscriptionState(subId, streamId, new PushExtension(m), null))
                          .ToArray();
            }

            var registered = await registry.RegisterProducer(streamId, streamProvider, streamProducer);

            registered.UnionWith(matches);

            return(registered);
        }
Example #4
0
        public async Task <ISet <PubSubSubscriptionState> > RegisterProducer(StreamId streamId, string streamProvider, IStreamProducerExtension streamProducer)
        {
            ISet <PubSubSubscriptionState> result = await explicitPubSub.RegisterProducer(streamId, streamProvider, streamProducer);

            if (String.IsNullOrWhiteSpace(streamId.Namespace))
            {
                return(result);
            }

            ISet <IStreamConsumerExtension> implicitSet = implicitPubSub.GetImplicitSubscribers(streamId);

            foreach (var consumer in implicitSet)
            {
                // we ignore duplicate entries-- there's no way a programmer could prevent the duplicate entry from being added if we threw an exception to communicate the problem.
                result.Add(new PubSubSubscriptionState(streamId, consumer, null, null));
            }
            return(result);
        }
        private async Task RegisterAsStreamProducer(StreamId streamId, StreamSequenceToken streamStartToken)
        {
            try
            {
                if (pubSub == null) throw new NullReferenceException("Found pubSub reference not set up correctly in RetreaveNewStream");

                IStreamProducerExtension meAsStreamProducer = this.AsReference<IStreamProducerExtension>();
                ISet<PubSubSubscriptionState> streamData = await pubSub.RegisterProducer(streamId, streamProviderName, meAsStreamProducer);
                if (logger.IsVerbose) logger.Verbose((int)ErrorCode.PersistentStreamPullingAgent_16, "Got back {0} Subscribers for stream {1}.", streamData.Count, streamId);

                var addSubscriptionTasks = new List<Task>(streamData.Count);
                foreach (PubSubSubscriptionState item in streamData)
                {
                    addSubscriptionTasks.Add(AddSubscriber_Impl(item.SubscriptionId, item.Stream, item.Consumer, streamStartToken, item.Filter));
                }
                await Task.WhenAll(addSubscriptionTasks);
            }
            catch (Exception exc)
            {
                // RegisterAsStreamProducer is fired with .Ignore so we should log if anything goes wrong, because there is no one to catch the exception
                logger.Error((int)ErrorCode.PersistentStreamPullingAgent_17, "Ignored RegisterAsStreamProducer Error", exc);
                throw;
            }
        }