在Rabbit MQ中发布消息时设置超时

时间:2019-10-18 12:20:52

标签: c# .net-core rabbitmq

以下代码段在RabbitMq中发布了消息。

var properties = channel.CreateBasicProperties();
                properties.Persistent = true;
                properties.DeliveryMode = (byte)deliveryMode;
                properties.Timestamp =  new AmqpTimestamp(Convert.ToInt64((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds));

                _logger.LogTrace("Publishing event to Queue: {EventId} with Timestamp: {Timestamp}", integrationEvent.Id, properties.Timestamp);

                channel.BasicPublish(
                      exchange: exchangeName,
                      routingKey: routingKey,
                      mandatory: true,
                      basicProperties: properties,
                      body: body
                      );

                channel.ConfirmSelect();

我想设置消息发布的超时时间。

0 个答案:

没有答案