
[英]Azure.Messaging.ServiceBus SendMessageAsync timing out every 2 min?
[英]Is there a way to get the Servicebus Sender.SendMessageAsync result if it is successfully sent?
我知道这听起来很愚蠢,但有什么办法可以得到 ServiceBus Sender.SendMessageAsnyc() 方法的结果? 我只是想确保我的消息发布到 Azure ServiceBus。
提前谢谢大家。
消息结算选项
ServiceBusSender
执行消息发送。 使用ServiceBusReceiver
执行接收。Complete
API 向代理发送肯定的确认。string connectionString = "<conn_string>";
string queueName = "<QueueName>";
// since ServiceBusClient implements IAsyncDisposable we create it with "await using"
await using var client = new ServiceBusClient(connectionString);
// create the sender
ServiceBusSender sender = client.CreateSender(queueName);
// create a message that we can send. UTF-8 encoding is used when providing a string.
ServiceBusMessage message = new ServiceBusMessage("Hello EveryOne!");
// send the message
await sender.SendMessageAsync(message);
// create a receiver that we can use to receive the message
ServiceBusReceiver receiver = client.CreateReceiver(queueName);
// the received message is a different type as it contains some service set properties
ServiceBusReceivedMessage receivedMessage = await receiver.ReceiveMessageAsync();
// get the message body as a string
string body = receivedMessage.Body.ToString();
Console.WriteLine(body);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.