mirror of https://github.com/abpframework/abp.git
19 changed files with 0 additions and 469 deletions
@ -1,14 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.EventBus.RabbitMQ\Volo.Abp.EventBus.RabbitMQ.csproj" /> |
|||
<ProjectReference Include="..\SharedModule\SharedModule.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -1,43 +0,0 @@ |
|||
using SharedModule; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace App1 |
|||
{ |
|||
public class App1MessagingService : ITransientDependency |
|||
{ |
|||
private readonly IDistributedEventBus _distributedEventBus; |
|||
|
|||
public App1MessagingService(IDistributedEventBus distributedEventBus) |
|||
{ |
|||
_distributedEventBus = distributedEventBus; |
|||
} |
|||
|
|||
public async Task RunAsync() |
|||
{ |
|||
Console.WriteLine("*** Started the APPLICATION 1 ***"); |
|||
Console.WriteLine("Write a message and press ENTER to send to the App2."); |
|||
Console.WriteLine("Press ENTER (without writing a message) to stop the application."); |
|||
|
|||
string message; |
|||
do |
|||
{ |
|||
Console.WriteLine(); |
|||
|
|||
message = Console.ReadLine(); |
|||
|
|||
if (!message.IsNullOrEmpty()) |
|||
{ |
|||
await _distributedEventBus.PublishAsync(new App1ToApp2TextEventData(message)); |
|||
} |
|||
else |
|||
{ |
|||
await _distributedEventBus.PublishAsync(new App1ToApp2TextEventData("App1 is exiting. Bye bye...!")); |
|||
} |
|||
|
|||
} while (!message.IsNullOrEmpty()); |
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.EventBus.RabbitMq; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace App1 |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpEventBusRabbitMqModule), |
|||
typeof(AbpAutofacModule) |
|||
)] |
|||
public class App1Module : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpRabbitMqEventBusOptions>(options => |
|||
{ |
|||
options.ClientName = "TestApp1"; |
|||
options.ExchangeName = "TestMessages"; |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using SharedModule; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace App1 |
|||
{ |
|||
/// <summary>
|
|||
/// Used to listen messages sent to App2 by App1.
|
|||
/// </summary>
|
|||
public class App1TextEventHandler : IDistributedEventHandler<App2ToApp1TextEventData>, ITransientDependency |
|||
{ |
|||
private readonly IDistributedEventBus _distributedEventBus; |
|||
|
|||
public App1TextEventHandler(IDistributedEventBus distributedEventBus) |
|||
{ |
|||
_distributedEventBus = distributedEventBus; |
|||
} |
|||
|
|||
public async Task HandleEventAsync(App2ToApp1TextEventData eventData) |
|||
{ |
|||
Console.WriteLine("************************ INCOMING MESSAGE ****************************"); |
|||
Console.WriteLine(eventData.TextMessage); |
|||
Console.WriteLine("**********************************************************************"); |
|||
Console.WriteLine(); |
|||
|
|||
await _distributedEventBus.PublishAsync(new App1TextReceivedEventData(eventData.TextMessage)); |
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using SharedModule; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace App1 |
|||
{ |
|||
/// <summary>
|
|||
/// Used to know when App2 has received a message sent by App1.
|
|||
/// </summary>
|
|||
public class App1TextReceivedEventHandler : IDistributedEventHandler<App2TextReceivedEventData>, ITransientDependency |
|||
{ |
|||
public Task HandleEventAsync(App2TextReceivedEventData eventData) |
|||
{ |
|||
Console.WriteLine("--------> App2 has received the message: " + eventData.ReceivedText.TruncateWithPostfix(32)); |
|||
Console.WriteLine(); |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp; |
|||
|
|||
namespace App1 |
|||
{ |
|||
internal class Program |
|||
{ |
|||
private static async Task Main(string[] args) |
|||
{ |
|||
using (var application = AbpApplicationFactory.Create<App1Module>(options => |
|||
{ |
|||
options.UseAutofac(); |
|||
})) |
|||
{ |
|||
application.Initialize(); |
|||
|
|||
var messagingService = application |
|||
.ServiceProvider |
|||
.GetRequiredService<App1MessagingService>(); |
|||
|
|||
await messagingService.RunAsync(); |
|||
|
|||
application.Shutdown(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,14 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.EventBus.RabbitMQ\Volo.Abp.EventBus.RabbitMQ.csproj" /> |
|||
<ProjectReference Include="..\SharedModule\SharedModule.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -1,43 +0,0 @@ |
|||
using SharedModule; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace App2 |
|||
{ |
|||
public class App2MessagingService : ITransientDependency |
|||
{ |
|||
private readonly IDistributedEventBus _distributedEventBus; |
|||
|
|||
public App2MessagingService(IDistributedEventBus distributedEventBus) |
|||
{ |
|||
_distributedEventBus = distributedEventBus; |
|||
} |
|||
|
|||
public async Task RunAsync() |
|||
{ |
|||
Console.WriteLine("*** Started the APPLICATION 2 ***"); |
|||
Console.WriteLine("Write a message and press ENTER to send to the App1."); |
|||
Console.WriteLine("Press ENTER (without writing a message) to stop the application..."); |
|||
|
|||
string message; |
|||
do |
|||
{ |
|||
Console.WriteLine(); |
|||
|
|||
message = Console.ReadLine(); |
|||
|
|||
if (!message.IsNullOrEmpty()) |
|||
{ |
|||
await _distributedEventBus.PublishAsync(new App2ToApp1TextEventData(message)); |
|||
} |
|||
else |
|||
{ |
|||
await _distributedEventBus.PublishAsync(new App2ToApp1TextEventData("App2 is exiting. Bye bye...!")); |
|||
} |
|||
|
|||
} while (!message.IsNullOrEmpty()); |
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.EventBus.RabbitMq; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace App2 |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpEventBusRabbitMqModule), |
|||
typeof(AbpAutofacModule) |
|||
)] |
|||
public class App2Module : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpRabbitMqEventBusOptions>(options => |
|||
{ |
|||
options.ClientName = "TestApp2"; |
|||
options.ExchangeName = "TestMessages"; |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using SharedModule; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace App2 |
|||
{ |
|||
/// <summary>
|
|||
/// Used to listen messages sent to App2 by App1.
|
|||
/// </summary>
|
|||
public class App2TextEventHandler : IDistributedEventHandler<App1ToApp2TextEventData>, ITransientDependency |
|||
{ |
|||
private readonly IDistributedEventBus _distributedEventBus; |
|||
|
|||
public App2TextEventHandler(IDistributedEventBus distributedEventBus) |
|||
{ |
|||
_distributedEventBus = distributedEventBus; |
|||
} |
|||
|
|||
public async Task HandleEventAsync(App1ToApp2TextEventData eventData) |
|||
{ |
|||
Console.WriteLine("************************ INCOMING MESSAGE ****************************"); |
|||
Console.WriteLine(eventData.TextMessage); |
|||
Console.WriteLine("**********************************************************************"); |
|||
Console.WriteLine(); |
|||
|
|||
await _distributedEventBus.PublishAsync(new App2TextReceivedEventData(eventData.TextMessage)); |
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using SharedModule; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace App2 |
|||
{ |
|||
/// <summary>
|
|||
/// Used to know when App1 has received a message sent by App2.
|
|||
/// </summary>
|
|||
public class App2TextReceivedEventHandler : IDistributedEventHandler<App1TextReceivedEventData>, ITransientDependency |
|||
{ |
|||
public Task HandleEventAsync(App1TextReceivedEventData eventData) |
|||
{ |
|||
Console.WriteLine("--------> App1 has received the message: " + eventData.ReceivedText.TruncateWithPostfix(32)); |
|||
Console.WriteLine(); |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp; |
|||
|
|||
namespace App2 |
|||
{ |
|||
internal class Program |
|||
{ |
|||
private static async Task Main(string[] args) |
|||
{ |
|||
using (var application = AbpApplicationFactory.Create<App2Module>(options => |
|||
{ |
|||
options.UseAutofac(); |
|||
})) |
|||
{ |
|||
application.Initialize(); |
|||
|
|||
var messagingService = application |
|||
.ServiceProvider |
|||
.GetRequiredService<App2MessagingService>(); |
|||
|
|||
await messagingService.RunAsync(); |
|||
|
|||
application.Shutdown(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,37 +0,0 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio 15 |
|||
VisualStudioVersion = 15.0.28010.2016 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App1", "App1\App1.csproj", "{2C93AFEF-1677-4591-8245-35D5E0F99B03}" |
|||
EndProject |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedModule", "SharedModule\SharedModule.csproj", "{D6F948FB-699B-45D7-8B79-F9D43B627B68}" |
|||
EndProject |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App2", "App2\App2.csproj", "{A5FE0CEF-C472-47DD-9F2B-DFFFA33B8523}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{2C93AFEF-1677-4591-8245-35D5E0F99B03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{2C93AFEF-1677-4591-8245-35D5E0F99B03}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{2C93AFEF-1677-4591-8245-35D5E0F99B03}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{2C93AFEF-1677-4591-8245-35D5E0F99B03}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{D6F948FB-699B-45D7-8B79-F9D43B627B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{D6F948FB-699B-45D7-8B79-F9D43B627B68}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{D6F948FB-699B-45D7-8B79-F9D43B627B68}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{D6F948FB-699B-45D7-8B79-F9D43B627B68}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{A5FE0CEF-C472-47DD-9F2B-DFFFA33B8523}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{A5FE0CEF-C472-47DD-9F2B-DFFFA33B8523}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{A5FE0CEF-C472-47DD-9F2B-DFFFA33B8523}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{A5FE0CEF-C472-47DD-9F2B-DFFFA33B8523}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {44A91B65-F109-4FD0-B6C0-63C052A5BEEB} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
@ -1,23 +0,0 @@ |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace SharedModule |
|||
{ |
|||
/// <summary>
|
|||
/// Used to indicate that App2 has received a text message.
|
|||
/// </summary>
|
|||
[EventName("Test.App1TextReceived")] //Optional event name
|
|||
public class App1TextReceivedEventData |
|||
{ |
|||
public string ReceivedText { get; set; } |
|||
|
|||
public App1TextReceivedEventData() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public App1TextReceivedEventData(string receivedText) |
|||
{ |
|||
ReceivedText = receivedText; |
|||
} |
|||
} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace SharedModule |
|||
{ |
|||
/// <summary>
|
|||
/// Used to send a text message from App1 to App2.
|
|||
/// </summary>
|
|||
[EventName("Test.App1ToApp2Text")] //Optional event name
|
|||
public class App1ToApp2TextEventData |
|||
{ |
|||
public string TextMessage { get; set; } |
|||
|
|||
public App1ToApp2TextEventData() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public App1ToApp2TextEventData(string textMessage) |
|||
{ |
|||
TextMessage = textMessage; |
|||
} |
|||
} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace SharedModule |
|||
{ |
|||
/// <summary>
|
|||
/// Used to indicate that App2 has received a text message.
|
|||
/// </summary>
|
|||
[EventName("Test.App2TextReceived")] //Optional event name
|
|||
public class App2TextReceivedEventData |
|||
{ |
|||
public string ReceivedText { get; set; } |
|||
|
|||
public App2TextReceivedEventData() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public App2TextReceivedEventData(string receivedText) |
|||
{ |
|||
ReceivedText = receivedText; |
|||
} |
|||
} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace SharedModule |
|||
{ |
|||
/// <summary>
|
|||
/// Used to send a text message from App2 to App1.
|
|||
/// </summary>
|
|||
[EventName("Test.App2ToApp1Text")] //Optional event name
|
|||
public class App2ToApp1TextEventData |
|||
{ |
|||
public string TextMessage { get; set; } |
|||
|
|||
public App2ToApp1TextEventData() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public App2ToApp1TextEventData(string textMessage) |
|||
{ |
|||
TextMessage = textMessage; |
|||
} |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.EventBus\Volo.Abp.EventBus.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
Loading…
Reference in new issue