Example #1
0
        private async Task SubscribeToEvents(SubscribeRequest subscribeRequest)
        {
            KubeMQGrpc.Subscribe innerSubscribeRequest = subscribeRequest.ToInnerSubscribeRequest();
            using (var call = GetKubeMQClient().SubscribeToEvents(innerSubscribeRequest, _metadata))
            {
                // Wait for event..
                while (await call.ResponseStream.MoveNext())
                {
                    // Received a event
                    InnerRecivedEvent eventReceive = call.ResponseStream.Current;

                    // add event to queue
                    _RecivedEvents.Post(eventReceive);
                    LogIncomingEvent(eventReceive);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Register to kubeMQ Channel using KubeMQ.SDK.csharp.Subscription.SubscribeRequest.
        /// </summary>
        /// <param name="subscribeRequest">Parameters list represent by KubeMQ.SDK.csharp.Subscription.SubscribeRequest that will determine the subscription configuration.</param>
        /// <param name="cancellationToken">Optional param if needed to cancel the subscriber ,will receive RPC exception with status canceled through the error Delegate is called.</param>
        /// <returns>A task that represents the Subscribe Request.</returns>
        private async Task SubscribeToRequests(SubscribeRequest subscribeRequest, CancellationToken cancellationToken)
        {
            KubeMQGrpc.Subscribe innerSubscribeRequest = subscribeRequest.ToInnerSubscribeRequest();

            using (var call = GetKubeMQClient().SubscribeToRequests(innerSubscribeRequest, Metadata, null, cancellationToken)) {
                // await for requests form GRPC stream.
                while (await call.ResponseStream.MoveNext())
                {
                    // Received requests form GRPC stream.
                    InnerRequest request = call.ResponseStream.Current;

                    LogRequest(request);

                    // Add (Post) request to queue
                    _RecivedRequests.Post(request);
                }
            }
        }