Commit e06209aa authored by yangxiaodong's avatar yangxiaodong

set rabbitmq use durable queue.

parent 4fbed6b3
// ReSharper disable once CheckNamespace
using System;
// ReSharper disable once CheckNamespace
namespace DotNetCore.CAP
{
public class RabbitMQOptions
......@@ -76,5 +78,10 @@ namespace DotNetCore.CAP
/// The port to connect on.
/// </summary>
public int Port { get; set; } = -1;
/// <summary>
/// Gets or sets queue message automatic deletion time. Default 10 days.
/// </summary>
public TimeSpan XMessageTTL { get; set; } = TimeSpan.FromDays(10);
}
}
\ No newline at end of file
......@@ -49,7 +49,11 @@ namespace DotNetCore.CAP.RabbitMQ
_connection = _connectionFactory.CreateConnection();
_channel = _connection.CreateModel();
_channel.ExchangeDeclare(exchange: _exchageName, type: RabbitMQOptions.ExchangeType);
_channel.QueueDeclare(_queueName, exclusive: false);
_channel.QueueDeclare(_queueName,
durable: true,
exclusive: false,
autoDelete: false,
arguments: new Dictionary<string, object> { { "message-ttl", _rabbitMQOptions.XMessageTTL.TotalMilliseconds } });
}
public void Subscribe(IEnumerable<string> topics)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment