-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
Example/Example.TLSConnection/Example.TLSConnection.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Src\NanoRabbit\NanoRabbit.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
using Microsoft.Extensions.Logging; | ||
using NanoRabbit; | ||
using NanoRabbit.Connection; | ||
using System.Security.Authentication; | ||
|
||
var loggerFactory = LoggerFactory.Create(builder => | ||
{ | ||
builder.AddConsole(); | ||
}); | ||
|
||
var logger = loggerFactory.CreateLogger("RabbitHelper"); | ||
|
||
var rabbitHelper = new RabbitHelper(rabbitConfig: new RabbitConfiguration | ||
{ | ||
HostName = "localhost", | ||
Port = 5672, | ||
VirtualHost = "/", | ||
UserName = "admin", | ||
Password = "admin", | ||
TLSConfig = new TLSConfig | ||
{ | ||
Enabled = true, | ||
CertPath = "/path/to/client_key.p12", | ||
CertPassphrase = "MySecretPassword", | ||
Version = SslProtocols.Ssl2 | ||
Check warning on line 26 in Example/Example.TLSConnection/Program.cs GitHub Actions / build (ubuntu-latest, net6.0)
Check warning on line 26 in Example/Example.TLSConnection/Program.cs GitHub Actions / build (ubuntu-latest, net7.0)
|
||
}, | ||
Producers = new List<ProducerOptions> { new ProducerOptions { | ||
ProducerName = "FooProducer", | ||
ExchangeName = "amq.topic", | ||
RoutingKey = "foo.key" | ||
} | ||
}, | ||
Consumers = new List<ConsumerOptions> { new ConsumerOptions { | ||
ConsumerName= "FooConsumer", | ||
QueueName = "foo-queue" | ||
} | ||
} | ||
}, logger); | ||
|
||
rabbitHelper.Publish<string>("FooProducer", "Hello from NanoRabbit"); | ||
|
||
Console.WriteLine(" Press [enter] to exit."); | ||
|
||
while (true) | ||
{ | ||
rabbitHelper.AddConsumer("FooConsumer", message => | ||
{ | ||
Console.WriteLine(message); | ||
}); | ||
|
||
if (Console.ReadLine() == "") | ||
{ | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters