Commit f184550a authored by yangxiaodong's avatar yangxiaodong

Fix RabbitMQ polling bug.

parent 0c1dffdd
...@@ -136,11 +136,10 @@ namespace DotNetCore.CAP.RabbitMQ ...@@ -136,11 +136,10 @@ namespace DotNetCore.CAP.RabbitMQ
using (var connection = factory.CreateConnection()) using (var connection = factory.CreateConnection())
using (var channel = connection.CreateModel()) using (var channel = connection.CreateModel())
{ {
channel.ExchangeDeclare(exchange: "topic_logs", channel.ExchangeDeclare(exchange: "test",
type: "topic"); type: "topic");
var body = Encoding.UTF8.GetBytes(content); var body = Encoding.UTF8.GetBytes(content);
channel.BasicPublish(exchange: "topic_logs", channel.BasicPublish(exchange: "test",
routingKey: topic, routingKey: topic,
basicProperties: null, basicProperties: null,
body: body); body: body);
......
using System; using System;
using System.Text; using System.Text;
using System.Threading.Tasks;
using DotNetCore.CAP.Infrastructure; using DotNetCore.CAP.Infrastructure;
using RabbitMQ.Client; using RabbitMQ.Client;
using RabbitMQ.Client.Events; using RabbitMQ.Client.Events;
...@@ -53,6 +54,10 @@ namespace DotNetCore.CAP.RabbitMQ ...@@ -53,6 +54,10 @@ namespace DotNetCore.CAP.RabbitMQ
var consumer = new EventingBasicConsumer(_channel); var consumer = new EventingBasicConsumer(_channel);
consumer.Received += OnConsumerReceived; consumer.Received += OnConsumerReceived;
_channel.BasicConsume(_queueName, true, consumer); _channel.BasicConsume(_queueName, true, consumer);
while (true)
{
Task.Delay(timeout);
}
} }
public void Subscribe(string topic) public void Subscribe(string topic)
......
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