Commit 96ff6a55 authored by Savorboard's avatar Savorboard

support multiple topic subscribe.

parent f8759398
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -51,6 +52,16 @@ namespace DotNetCore.CAP.RabbitMQ ...@@ -51,6 +52,16 @@ namespace DotNetCore.CAP.RabbitMQ
_channel.QueueDeclare(_queueName, exclusive: false); _channel.QueueDeclare(_queueName, exclusive: false);
} }
public void Subscribe(IEnumerable<string> topics)
{
if (topics == null) throw new ArgumentNullException(nameof(topics));
foreach (var topic in topics)
{
_channel.QueueBind(_queueName, _exchageName, topic);
}
}
public void Listening(TimeSpan timeout, CancellationToken cancellationToken) public void Listening(TimeSpan timeout, CancellationToken cancellationToken)
{ {
var consumer = new EventingBasicConsumer(_channel); var consumer = new EventingBasicConsumer(_channel);
...@@ -63,16 +74,6 @@ namespace DotNetCore.CAP.RabbitMQ ...@@ -63,16 +74,6 @@ namespace DotNetCore.CAP.RabbitMQ
} }
} }
public void Subscribe(string topic)
{
_channel.QueueBind(_queueName, _exchageName, topic);
}
public void Subscribe(string topic, int partition)
{
_channel.QueueBind(_queueName, _exchageName, topic);
}
public void Commit() public void Commit()
{ {
_channel.BasicAck(_deliveryTag, false); _channel.BasicAck(_deliveryTag, false);
......
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