Browse Source

set rabbitmq use durable queue.

master
yangxiaodong 7 years ago
parent
commit
e06209aa72
2 changed files with 13 additions and 2 deletions
  1. +8
    -1
      src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs
  2. +5
    -1
      src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs

+ 8
- 1
src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs View File

@@ -1,4 +1,6 @@
// 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);
}
}

+ 5
- 1
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs View 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)


Loading…
Cancel
Save