From 1ebe284f4105e1f09d4dfec5a3e62cf617660047 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Mon, 17 Dec 2018 16:06:38 +0300 Subject: [PATCH] Connect to rabbitmq on startup. make methods virtual. --- .../Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs index 25ba3a2aa4..a41054a45f 100644 --- a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs +++ b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs @@ -46,6 +46,7 @@ namespace Volo.Abp.RabbitMQ Timer.Period = 5000; //5 sec. Timer.Elapsed += Timer_Elapsed; + Timer.RunOnStart = true; } public void Initialize( @@ -59,19 +60,19 @@ namespace Volo.Abp.RabbitMQ Timer.Start(); } - public async Task BindAsync(string routingKey) + public virtual async Task BindAsync(string routingKey) { QueueBindCommands.Enqueue(new QueueBindCommand(QueueBindType.Bind, routingKey)); await TrySendQueueBindCommandsAsync(); } - public async Task UnbindAsync(string routingKey) + public virtual async Task UnbindAsync(string routingKey) { QueueBindCommands.Enqueue(new QueueBindCommand(QueueBindType.Unbind, routingKey)); await TrySendQueueBindCommandsAsync(); } - protected Task TrySendQueueBindCommandsAsync() + protected virtual Task TrySendQueueBindCommandsAsync() { try { @@ -118,7 +119,7 @@ namespace Volo.Abp.RabbitMQ return Task.CompletedTask; } - public void OnMessageReceived(Func callback) + public virtual void OnMessageReceived(Func callback) { Callbacks.Add(callback); } @@ -132,7 +133,7 @@ namespace Volo.Abp.RabbitMQ } } - private void TryCreateChannel() + protected virtual void TryCreateChannel() { DisposeChannel(); @@ -214,7 +215,7 @@ namespace Volo.Abp.RabbitMQ DisposeChannel(); } - public class QueueBindCommand + protected class QueueBindCommand { public QueueBindType Type { get; } @@ -227,7 +228,7 @@ namespace Volo.Abp.RabbitMQ } } - public enum QueueBindType + protected enum QueueBindType { Bind, Unbind