Kaynağa Gözat

set exchange and queue with durable.

master
yangxiaodong 7 yıl önce
ebeveyn
işleme
343e409508
2 değiştirilmiş dosya ile 9 ekleme ve 3 silme
  1. +1
    -1
      src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs
  2. +8
    -2
      src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs

+ 1
- 1
src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs Dosyayı Görüntüle

@@ -43,7 +43,7 @@ namespace DotNetCore.CAP.RabbitMQ
{
var body = Encoding.UTF8.GetBytes(content);

channel.ExchangeDeclare(_rabbitMQOptions.TopicExchangeName, RabbitMQOptions.ExchangeType);
channel.ExchangeDeclare(_rabbitMQOptions.TopicExchangeName, RabbitMQOptions.ExchangeType, durable: true);
channel.BasicPublish(exchange: _rabbitMQOptions.TopicExchangeName,
routingKey: keyName,
basicProperties: null,


+ 8
- 2
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs Dosyayı Görüntüle

@@ -48,12 +48,18 @@ namespace DotNetCore.CAP.RabbitMQ

_connection = _connectionFactory.CreateConnection();
_channel = _connection.CreateModel();
_channel.ExchangeDeclare(exchange: _exchageName, type: RabbitMQOptions.ExchangeType);

_channel.ExchangeDeclare(
exchange: _exchageName,
type: RabbitMQOptions.ExchangeType,
durable: true);

var arguments = new Dictionary<string, object> { { "x-message-ttl", (int)_rabbitMQOptions.XMessageTTL.TotalMilliseconds } };
_channel.QueueDeclare(_queueName,
durable: true,
exclusive: false,
autoDelete: false,
arguments: new Dictionary<string, object> { { "message-ttl", _rabbitMQOptions.XMessageTTL.TotalMilliseconds } });
arguments: arguments);
}

public void Subscribe(IEnumerable<string> topics)


Yükleniyor…
İptal
Kaydet