Ejemplo n.º 1
0
        public async Task <ISubscriber> CreateSubscriber(string topicName, string subscriptionName, Action <ISubscriber, IEnumerable <Message> > messagesHandler)
        {
            var duplexStream = grpcClient.Subscribe();
            await duplexStream.RequestStream.WriteAsync(new FastQueueService.CompleteRequest
            {
                TopicName        = topicName,
                SubscriptionName = subscriptionName
            });

            var subscriber = new Subscriber(duplexStream, messagesHandler);

            subscriber.StartReceivingLoop();
            return(subscriber);
        }
Ejemplo n.º 2
0
        private async Task <ISubscriber> CreateSubscriberInternal(string topicName, string subscriptionName, SubscriberOptions options,
                                                                  Func <AsyncDuplexStreamingCall <FastQueueService.CompleteRequest, FastQueueService.MessageBatch>, Subscriber> subscriberFactory)
        {
            var opt          = options ?? new SubscriberOptions();
            var duplexStream = grpcClient.Subscribe();
            await duplexStream.RequestStream.WriteAsync(new FastQueueService.CompleteRequest
            {
                Options = new FastQueueService.SubscriberOptions
                {
                    TopicName                = topicName,
                    SubscriptionName         = subscriptionName,
                    MaxMessagesInBatch       = opt.MaxMessagesInBatch,
                    PushIntervalMilliseconds = opt.PushIntervalMilliseconds
                }
            });

            var subscriber = subscriberFactory(duplexStream);

            subscriber.StartReceivingLoop();
            return(subscriber);
        }