public async Task <string> Publish(string message) { await Limiter.Add(1); await using (var context = new AzureMessagingContext(QueueUrl)) { var msg = new azureMessaging.ServiceBusMessage(message); await context.Sender.SendMessageAsync(msg); return(msg.MessageId); } }
public async Task <string> Publish(string message) { await Limiter.Add(1); var request = new SendMessageRequest { QueueUrl = QueueUrl, MessageBody = message, }; if (IsFifo) { request.MessageDeduplicationId = JsonConvert.DeserializeObject <JObject>(message)["DeduplicationId"]?.ToString(); request.MessageGroupId = "Default"; } var response = await Client.SendMessageAsync(request); return(response.MessageId); }
public async Task <string> Publish(string message) { await Limiter.Add(1); var body = Encoding.UTF8.GetBytes(message); Client.QueueDeclare(QueueUrl, true, false, false, null); Client.ExchangeDeclare(exchange: QueueUrl, type: ExchangeType.Fanout, durable: true); Client.QueueBind(queue: QueueUrl, exchange: QueueUrl, routingKey: QueueUrl); var properties = Client.CreateBasicProperties(); properties.Persistent = true; properties.ContentType = "application/json"; Client.BasicPublish("", routingKey: QueueUrl, basicProperties: properties, body: body); return(""); }