Skip to content

Commit

Permalink
Add Exmaple.TLSConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
ifgris committed Sep 4, 2024
1 parent df6d667 commit d87ec2b
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Example/Example.TLSConnection/Example.TLSConnection.csproj
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>
56 changes: 56 additions & 0 deletions Example/Example.TLSConnection/Program.cs
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

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net6.0)

'SslProtocols.Ssl2' is obsolete: 'SslProtocols.Ssl2 has been deprecated and is not supported.'

Check warning on line 26 in Example/Example.TLSConnection/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net7.0)

'SslProtocols.Ssl2' is obsolete: 'SslProtocols.Ssl2 has been deprecated and is not supported.'

Check warning on line 26 in Example/Example.TLSConnection/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, net8.0)

'SslProtocols.Ssl2' is obsolete: 'SslProtocols.Ssl2 has been deprecated and is not supported.'
},
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;
}
}
7 changes: 7 additions & 0 deletions NanoRabbit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.SpecifyMessagesPropert
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.WebApplication", "Example\Example.WebApplication\Example.WebApplication.csproj", "{3169FF28-0BA6-4391-AB6F-F6BDEC75E596}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.TLSConnection", "Example\Example.TLSConnection\Example.TLSConnection.csproj", "{0C45AA1B-CC42-4A1A-A8AC-90DF2CE99F59}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -107,6 +109,10 @@ Global
{3169FF28-0BA6-4391-AB6F-F6BDEC75E596}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3169FF28-0BA6-4391-AB6F-F6BDEC75E596}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3169FF28-0BA6-4391-AB6F-F6BDEC75E596}.Release|Any CPU.Build.0 = Release|Any CPU
{0C45AA1B-CC42-4A1A-A8AC-90DF2CE99F59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C45AA1B-CC42-4A1A-A8AC-90DF2CE99F59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C45AA1B-CC42-4A1A-A8AC-90DF2CE99F59}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C45AA1B-CC42-4A1A-A8AC-90DF2CE99F59}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -129,6 +135,7 @@ Global
{25D1ECC8-3A50-43A7-B7D5-78068222254E} = {DE278D07-341E-425C-B687-BB3CD9F9757D}
{012ACF78-7FA0-4754-A271-97D57D01D324} = {DE278D07-341E-425C-B687-BB3CD9F9757D}
{3169FF28-0BA6-4391-AB6F-F6BDEC75E596} = {D187C758-604D-4325-9FEF-912DB32D6131}
{0C45AA1B-CC42-4A1A-A8AC-90DF2CE99F59} = {D187C758-604D-4325-9FEF-912DB32D6131}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6EE19DFD-83A9-4A48-B245-5A1344E7865A}
Expand Down

0 comments on commit d87ec2b

Please sign in to comment.