chore: 消除构建警告并升级依赖
This commit is contained in:
@@ -25,14 +25,15 @@ public sealed class RabbitMqMessagePublisher(RabbitMqConnectionFactory connectio
|
||||
EnsureChannel();
|
||||
var options = optionsMonitor.CurrentValue;
|
||||
|
||||
_channel!.ExchangeDeclare(options.Exchange, options.ExchangeType, durable: true, autoDelete: false);
|
||||
var channel = _channel ?? throw new InvalidOperationException("RabbitMQ channel is not available.");
|
||||
channel.ExchangeDeclare(options.Exchange, options.ExchangeType, durable: true, autoDelete: false);
|
||||
var body = serializer.Serialize(message);
|
||||
var props = _channel.CreateBasicProperties();
|
||||
var props = channel.CreateBasicProperties();
|
||||
props.ContentType = "application/json";
|
||||
props.DeliveryMode = 2;
|
||||
props.MessageId = Guid.NewGuid().ToString("N");
|
||||
|
||||
_channel.BasicPublish(options.Exchange, routingKey, props, body);
|
||||
channel.BasicPublish(options.Exchange, routingKey, props, body);
|
||||
logger.LogDebug("发布消息到交换机 {Exchange} RoutingKey {RoutingKey}", options.Exchange, routingKey);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user