public async Task SendToQueueAsJson(string queueName,
                                            string data,
                                            IDictionary <string, string> properties,
                                            bool compressData   = false,
                                            string sessionId    = null,
                                            int?processingDelay = null)
        {
            Guard.IsNullOrWhiteSpace(queueName, nameof(queueName));

            Message message = ConstructMessage(data, compressData, sessionId);

            foreach (KeyValuePair <string, string> property in properties)
            {
                message.UserProperties.Add(property.Key, property.Value);
            }

            if (processingDelay.HasValue)
            {
                message.ScheduledEnqueueTimeUtc = DateTime.UtcNow.AddMinutes(processingDelay.Value);
            }

            AzureServiceBus.IQueueClient queueClient = _managementClient.GetQueueClient(queueName);

            await queueClient.SendAsync(message);
        }
Ejemplo n.º 2
0
        public async Task EnqueueManagementJob(ExecuteManagementJobCommand command)
        {
            var message = new Message(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(command)));

            message.ScheduledEnqueueTimeUtc = DateTime.UtcNow.AddSeconds(20);
            message.ContentType             = "application/json";

            await _QueueClient.SendAsync(message);
        }
Ejemplo n.º 3
0
        public async Task SendMessageAsync(Message msg)
        {
            try
            {
                // Serialize data model and create message.
                string messageBody = JsonSerializer.Serialize(msg);
                var    message     = new AzureServiceBus.Message(Encoding.UTF8.GetBytes(messageBody));

                // Send the message to the queue.
                await _queueClient.SendAsync(message);
            }
            catch (Exception ex)
            {
            }
        }