Browse Source
Merge pull request #1683 from dcagnetta/dev
Fix: IEventBus only has PublishAsync method - replaced Publish
pull/1701/head
maliming
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
24 additions and
26 deletions
-
samples/RabbitMqEventBus/App1/App1MessagingService.cs
-
samples/RabbitMqEventBus/App1/App1TextEventHandler.cs
-
samples/RabbitMqEventBus/App1/Program.cs
-
samples/RabbitMqEventBus/App2/App2MessagingService.cs
-
samples/RabbitMqEventBus/App2/App2TextEventHandler.cs
-
samples/RabbitMqEventBus/App2/Program.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()); |
|
|
|
|
|
|
|
@ -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)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -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<App1Module>(options => |
|
|
|
{ |
|
|
|
@ -18,7 +19,7 @@ namespace App1 |
|
|
|
.ServiceProvider |
|
|
|
.GetRequiredService<App1MessagingService>(); |
|
|
|
|
|
|
|
messagingService.Run(); |
|
|
|
await messagingService.RunAsync(); |
|
|
|
|
|
|
|
application.Shutdown(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -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()); |
|
|
|
|
|
|
|
@ -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)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -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<App2Module>(options => |
|
|
|
{ |
|
|
|
@ -18,7 +19,7 @@ namespace App2 |
|
|
|
.ServiceProvider |
|
|
|
.GetRequiredService<App2MessagingService>(); |
|
|
|
|
|
|
|
messagingService.Run(); |
|
|
|
await messagingService.RunAsync(); |
|
|
|
|
|
|
|
application.Shutdown(); |
|
|
|
} |
|
|
|
|