-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
0a3ab2b
commit 5aeabe9
Showing
5 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<UserSecretsId>ffbcfb1f-57f6-4fca-96ae-4a0e2b43c970</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Npgmq\Npgmq.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" /> | ||
</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,33 @@ | ||
using System.Reflection; | ||
using Microsoft.Extensions.Configuration; | ||
using Npgmq; | ||
|
||
var configuration = new ConfigurationBuilder() | ||
.AddEnvironmentVariables() | ||
.AddUserSecrets(Assembly.GetExecutingAssembly()) | ||
.Build(); | ||
|
||
var npgmq = new NpgmqClient(configuration.GetConnectionString("ExampleDB")!); | ||
|
||
await npgmq.InitAsync(); | ||
await npgmq.CreateQueueAsync("example_queue"); | ||
|
||
var msgId = await npgmq.SendAsync("example_queue", new MyMessageType | ||
{ | ||
Foo = "Test", | ||
Bar = 123 | ||
}); | ||
Console.WriteLine($"Sent message with id {msgId}"); | ||
|
||
var msg = await npgmq.ReadAsync<MyMessageType>("example_queue"); | ||
if (msg != null) | ||
{ | ||
Console.WriteLine($"Read message with id {msg.MsgId}: Foo = {msg.Message?.Foo}, Bar = {msg.Message?.Bar}"); | ||
await npgmq.ArchiveAsync("example_queue", msg.MsgId); | ||
} | ||
|
||
internal class MyMessageType | ||
{ | ||
public string Foo { get; set; } = null!; | ||
public int Bar { get; set; } | ||
} |
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,3 @@ | ||
# Npgmq.Example | ||
|
||
Example project for Npgmq. |
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
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