From 257257c834fafe2f5e5063d7c5987f79ad87f689 Mon Sep 17 00:00:00 2001 From: Dillan Cagnetta Date: Mon, 26 Aug 2019 08:59:14 +0200 Subject: [PATCH] Fix: IEventBus only has PublishAsync method - replaced Publish --- .../RabbitMqEventBus/App1/App1MessagingService.cs | 12 ++++++------ .../RabbitMqEventBus/App1/App1TextEventHandler.cs | 6 ++---- samples/RabbitMqEventBus/App1/Program.cs | 7 ++++--- .../RabbitMqEventBus/App2/App2MessagingService.cs | 12 ++++++------ .../RabbitMqEventBus/App2/App2TextEventHandler.cs | 6 ++---- samples/RabbitMqEventBus/App2/Program.cs | 7 ++++--- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/samples/RabbitMqEventBus/App1/App1MessagingService.cs b/samples/RabbitMqEventBus/App1/App1MessagingService.cs index b8123d84d4..9ed72867bb 100644 --- a/samples/RabbitMqEventBus/App1/App1MessagingService.cs +++ b/samples/RabbitMqEventBus/App1/App1MessagingService.cs @@ -1,7 +1,7 @@ -using System; -using SharedModule; +using SharedModule; +using System; +using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -using Volo.Abp.EventBus; using Volo.Abp.EventBus.Distributed; namespace App1 @@ -15,7 +15,7 @@ namespace App1 _distributedEventBus = distributedEventBus; } - public void Run() + public async Task RunAsync() { Console.WriteLine("*** Started the APPLICATION 1 ***"); Console.WriteLine("Write a message and press ENTER to send to the App2."); @@ -30,11 +30,11 @@ namespace App1 if (!message.IsNullOrEmpty()) { - _distributedEventBus.Publish(new App1ToApp2TextEventData(message)); + await _distributedEventBus.PublishAsync(new App1ToApp2TextEventData(message)); } else { - _distributedEventBus.Publish(new App1ToApp2TextEventData("App1 is exiting. Bye bye...!")); + await _distributedEventBus.PublishAsync(new App1ToApp2TextEventData("App1 is exiting. Bye bye...!")); } } while (!message.IsNullOrEmpty()); diff --git a/samples/RabbitMqEventBus/App1/App1TextEventHandler.cs b/samples/RabbitMqEventBus/App1/App1TextEventHandler.cs index 046eda56b1..8a13adace0 100644 --- a/samples/RabbitMqEventBus/App1/App1TextEventHandler.cs +++ b/samples/RabbitMqEventBus/App1/App1TextEventHandler.cs @@ -18,16 +18,14 @@ namespace App1 _distributedEventBus = distributedEventBus; } - public Task HandleEventAsync(App2ToApp1TextEventData eventData) + public async Task HandleEventAsync(App2ToApp1TextEventData eventData) { Console.WriteLine("************************ INCOMING MESSAGE ****************************"); Console.WriteLine(eventData.TextMessage); Console.WriteLine("**********************************************************************"); Console.WriteLine(); - _distributedEventBus.PublishAsync(new App1TextReceivedEventData(eventData.TextMessage)); - - return Task.CompletedTask; + await _distributedEventBus.PublishAsync(new App1TextReceivedEventData(eventData.TextMessage)); } } } diff --git a/samples/RabbitMqEventBus/App1/Program.cs b/samples/RabbitMqEventBus/App1/Program.cs index 26decc1248..47c474c8c6 100644 --- a/samples/RabbitMqEventBus/App1/Program.cs +++ b/samples/RabbitMqEventBus/App1/Program.cs @@ -1,11 +1,12 @@ -using Microsoft.Extensions.DependencyInjection; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp; namespace App1 { internal class Program { - private static void Main(string[] args) + private static async Task Main(string[] args) { using (var application = AbpApplicationFactory.Create(options => { @@ -18,7 +19,7 @@ namespace App1 .ServiceProvider .GetRequiredService(); - messagingService.Run(); + await messagingService.RunAsync(); application.Shutdown(); } diff --git a/samples/RabbitMqEventBus/App2/App2MessagingService.cs b/samples/RabbitMqEventBus/App2/App2MessagingService.cs index b89e9dd960..05c6661979 100644 --- a/samples/RabbitMqEventBus/App2/App2MessagingService.cs +++ b/samples/RabbitMqEventBus/App2/App2MessagingService.cs @@ -1,7 +1,7 @@ -using System; -using SharedModule; +using SharedModule; +using System; +using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -using Volo.Abp.EventBus; using Volo.Abp.EventBus.Distributed; namespace App2 @@ -15,7 +15,7 @@ namespace App2 _distributedEventBus = distributedEventBus; } - public void Run() + public async Task RunAsync() { Console.WriteLine("*** Started the APPLICATION 2 ***"); Console.WriteLine("Write a message and press ENTER to send to the App1."); @@ -30,11 +30,11 @@ namespace App2 if (!message.IsNullOrEmpty()) { - _distributedEventBus.Publish(new App2ToApp1TextEventData(message)); + await _distributedEventBus.PublishAsync(new App2ToApp1TextEventData(message)); } else { - _distributedEventBus.Publish(new App2ToApp1TextEventData("App2 is exiting. Bye bye...!")); + await _distributedEventBus.PublishAsync(new App2ToApp1TextEventData("App2 is exiting. Bye bye...!")); } } while (!message.IsNullOrEmpty()); diff --git a/samples/RabbitMqEventBus/App2/App2TextEventHandler.cs b/samples/RabbitMqEventBus/App2/App2TextEventHandler.cs index 8cf9ef65ae..a43a910726 100644 --- a/samples/RabbitMqEventBus/App2/App2TextEventHandler.cs +++ b/samples/RabbitMqEventBus/App2/App2TextEventHandler.cs @@ -18,16 +18,14 @@ namespace App2 _distributedEventBus = distributedEventBus; } - public Task HandleEventAsync(App1ToApp2TextEventData eventData) + public async Task HandleEventAsync(App1ToApp2TextEventData eventData) { Console.WriteLine("************************ INCOMING MESSAGE ****************************"); Console.WriteLine(eventData.TextMessage); Console.WriteLine("**********************************************************************"); Console.WriteLine(); - _distributedEventBus.PublishAsync(new App2TextReceivedEventData(eventData.TextMessage)); - - return Task.CompletedTask; + await _distributedEventBus.PublishAsync(new App2TextReceivedEventData(eventData.TextMessage)); } } } diff --git a/samples/RabbitMqEventBus/App2/Program.cs b/samples/RabbitMqEventBus/App2/Program.cs index 2686c54e8f..75eb872edf 100644 --- a/samples/RabbitMqEventBus/App2/Program.cs +++ b/samples/RabbitMqEventBus/App2/Program.cs @@ -1,11 +1,12 @@ -using Microsoft.Extensions.DependencyInjection; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp; namespace App2 { internal class Program { - private static void Main(string[] args) + private static async Task Main(string[] args) { using (var application = AbpApplicationFactory.Create(options => { @@ -18,7 +19,7 @@ namespace App2 .ServiceProvider .GetRequiredService(); - messagingService.Run(); + await messagingService.RunAsync(); application.Shutdown(); }