gpt4 book ai didi

azure - 在哪里设置 Azure ServiceBus 超时

转载 作者:行者123 更新时间:2023-12-01 12:38:05 25 4
gpt4 key购买 nike

默认设置为 60 秒,但我需要将其调整为 30。我通过执行以下操作来创建所有消息:

 public void SendMessage<T>(T message)
{
string conn = "Microsoft.ServiceBus.ConnectionString." + message.GetType().Name;
string queueName = ConfigurationManager.AppSettings[message.GetType().Name + "QueueName"];
string connectionString = ConfigurationManager.AppSettings[conn];
QueueClient Client = QueueClient.CreateFromConnectionString(connectionString, queueName);
var m = new BrokeredMessage();
m.Properties["body"] = JsonConvert.SerializeObject(message);
Client.Send(m);
}

在哪里可以设置向 ServiceBus 发送消息的超时时间?目前服务总线已关闭,因此这给我带来了真正的问题:(

最佳答案

您可以使用 MessagingFactorySettings 更改超时:

        Uri serviceBusUri = ServiceBusEnvironment.CreateServiceUri("sb", "[serviceNamespace]", string.Empty);

MessagingFactorySettings factorySettings = new MessagingFactorySettings()
{
TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("[keyName]", "[sharedAccessKey]"),
OperationTimeout = TimeSpan.FromSeconds(30),
};

MessagingFactory messagingFactory = MessagingFactory.Create(serviceBusUri, factorySettings);
QueueClient Client = messagingFactory.CreateQueueClient("[QueueName]");

关于azure - 在哪里设置 Azure ServiceBus 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27732031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com