Пример #1
0
        /// <summary>
        /// Asynchronously adds a metadata payload to Google PubSub
        /// </summary>
        /// <param name="metadata">metadata to add to queue</param>
        /// <returns>success of operation</returns>
        public async Task <bool> Enqueue(QueueMetadata metadata)
        {
            try
            {
                PublisherServiceApiClient publisher = PublisherServiceApiClient.Create();

                TopicName topicName = new TopicName(this.cloud.GoogleProjectID, this.cloud.QueueName);
                await this.CreateTopicIfNotExistsAsync(publisher, topicName);

                var message = new PubsubMessage()
                {
                    Data = ByteString.CopyFromUtf8(JsonConvert.SerializeObject(metadata)),
                };

                var messageList = new List <PubsubMessage>()
                {
                    message
                };

                await publisher.PublishAsync(topicName, messageList);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Asynchronously adds a metadata payload to Azure storage queue
        /// </summary>
        /// <param name="metadata">metadata to add to queue</param>
        /// <returns>success of operation</returns>
        public async Task <bool> Enqueue(QueueMetadata metadata)
        {
            CloudQueueMessage message = new CloudQueueMessage(JsonConvert.SerializeObject(metadata));

            await this.cloudQueue.AddMessageAsync(message);

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Mocks adding a metadata payload to cloud queue
        /// </summary>
        /// <param name="metadata">metadata to add to queue</param>
        /// <returns>success of operation</returns>
        public async Task <bool> Enqueue(QueueMetadata metadata)
        {
            if (this.shouldSuccceed)
            {
                this.queue.Enqueue(metadata);
            }

            return(this.shouldSuccceed);
        }