在哪里设置 Azure ServiceBus 超时

where do I set Azure ServiceBus timeout

默认设置为 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]");