【发布时间】:2020-02-07 14:09:47
【问题描述】:
For some reason, I cannot send the message to the Service Bus Queue in my web job. Is this a limitation of a webjob that I cannot send an async request? I've tried downgrading and upgrading all the packages and even changing the .net framework, but nothing works.
规格: 1. 网络框架 4.6.1 2.Microsoft.Azure.Amqp 2.4.3 3.Microsoft.Azure.ServiceBus 4.1.1 4.Microsoft.Azure.WebJobs 2.2.0 5.Microsoft.Azure.WebJobs.Core 2.2.0 6.Newtonsoft.Json 12.0.3 7.WindowsAzure.Storage 9.3.3
代码:
public bool AddoQueue(string message)
{
_sendMessage.SendMessageToQueue(message);
return true;
}
static IQueueClient queueClient;
public async Task<bool> SendMessageToQueue(string message)
{
try
{
queueClient = new QueueClient(Configurator.GetConfigSettings("SBConnectionString"), Configurator.GetConfigSettings("QueueName"));
var messageObj = new Message(Encoding.UTF8.GetBytes(message))
{
TimeToLive = TimeSpan.FromDays(6),
PartitionKey = message
};
await queueClient.SendAsync(messageObj);
return true;
}
catch (Exception e)
{
Console.Write(e);
return false;
}
}
【问题讨论】:
标签: azure asynchronous queue servicebus