コード例 #1
0
        public async Task <bool> AddAsync(
            MessageAddOptions messageAddOptions)
        {
            var eventGridEventList =
                new List <EventGridEvent>();

            var topicCredentials =
                new TopicCredentials(
                    _options.TopicKey);

            var eventGridClient =
                new EventGridClient(
                    topicCredentials);

            var eventGridEvent =
                new EventGridEvent()
            {
                Id          = messageAddOptions.Id.ToString(),
                Subject     = messageAddOptions.Subject,
                EventType   = messageAddOptions.Type,
                Data        = messageAddOptions.Data,
                EventTime   = messageAddOptions.Time,
                DataVersion = messageAddOptions.DataVersion
            };

            eventGridEventList.Add(
                eventGridEvent);

            await eventGridClient.PublishEventsAsync(
                new Uri(_options.TopicEndpoint).Host, eventGridEventList);

            return(true);
        }
コード例 #2
0
        public async Task <bool> AddAsync(
            MessageAddOptions messageAddOptions)
        {
            var queueClient =
                new QueueClient(_options.ConnectionString, messageAddOptions.Type);


            var message =
                new Message(
                    Encoding.UTF8.GetBytes(
                        JsonConvert.SerializeObject(messageAddOptions, Formatting.Indented)));

            await queueClient.SendAsync(message);

            return(true);
        }
コード例 #3
0
        public async Task <bool> AddAsync(
            MessageAddOptions messageAddOptions)
        {
            var cloudStorageAccount =
                CloudStorageAccount.Parse(_options.ConnectionString);

            var cloudQueueClient =
                cloudStorageAccount.CreateCloudQueueClient();

            var cloudQueue =
                cloudQueueClient.GetQueueReference(messageAddOptions.Type);

            await cloudQueue.CreateIfNotExistsAsync();

            var cloudQueueMessage =
                new CloudQueueMessage(
                    JsonConvert.SerializeObject(messageAddOptions, Formatting.Indented));

            await cloudQueue.AddMessageAsync(cloudQueueMessage);

            return(true);
        }
コード例 #4
0
        public async Task <bool> AddAsync(
            MessageAddOptions messageAddOptions)
        {
            var connectionStringBuilder =
                new EventHubsConnectionStringBuilder(_options.ConnectionString)
            {
                EntityPath = messageAddOptions.Type
            };


            var eventHubClient =
                EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());

            await eventHubClient.SendAsync(
                new EventData(
                    Encoding.UTF8.GetBytes(
                        JsonConvert.SerializeObject(messageAddOptions, Formatting.Indented))));

            await eventHubClient.CloseAsync();

            return(true);
        }