diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bd171e7..648880b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -42,9 +42,12 @@ jobs:
- name: Build
run: dotnet build --no-restore --configuration Release /p:Version=${{ env.VERSION }} /p:CopyrightYear=$(date +%Y)
- - name: Test
+ - name: Test (latest pgmq version)
run: Npgmq.Test/scripts/run-tests.sh
+ - name: Test (pgmq 1.1.1)
+ run: Npgmq.Test/scripts/run-tests.sh 1.1.1
+
- name: Test (pgmq 1.0.0)
run: Npgmq.Test/scripts/run-tests.sh 1.0.0
diff --git a/Npgmq.Example/Npgmq.Example.csproj b/Npgmq.Example/Npgmq.Example.csproj
new file mode 100644
index 0000000..e9e7233
--- /dev/null
+++ b/Npgmq.Example/Npgmq.Example.csproj
@@ -0,0 +1,20 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+ ffbcfb1f-57f6-4fca-96ae-4a0e2b43c970
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Npgmq.Example/Program.cs b/Npgmq.Example/Program.cs
new file mode 100644
index 0000000..72ce1dc
--- /dev/null
+++ b/Npgmq.Example/Program.cs
@@ -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("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; }
+}
\ No newline at end of file
diff --git a/Npgmq.Example/README.md b/Npgmq.Example/README.md
new file mode 100644
index 0000000..faade7a
--- /dev/null
+++ b/Npgmq.Example/README.md
@@ -0,0 +1,3 @@
+# Npgmq.Example
+
+Example project for Npgmq.
diff --git a/Npgmq.Test/README.md b/Npgmq.Test/README.md
index a360a56..e069af4 100644
--- a/Npgmq.Test/README.md
+++ b/Npgmq.Test/README.md
@@ -21,6 +21,7 @@ scripts/run-tests.sh 1.1.1
```
### Start Database Only
+This can be helpful if you want to manually run tests, without having to start the database each time.
```bash
scripts/start-db.sh
diff --git a/Npgmq.Test/scripts/start-db.sh b/Npgmq.Test/scripts/start-db.sh
index 7e80215..508f356 100755
--- a/Npgmq.Test/scripts/start-db.sh
+++ b/Npgmq.Test/scripts/start-db.sh
@@ -4,6 +4,7 @@ set -e
PGMQ_VERSION=$1
docker run -d --name npgmq_test_db -p 5432:5432 --rm quay.io/tembo/tembo-local
+sleep 4
docker exec npgmq_test_db /bin/sh -c "psql -c \"CREATE DATABASE npgmq_test;\""
diff --git a/Npgmq.sln b/Npgmq.sln
index e1461d6..21e8272 100644
--- a/Npgmq.sln
+++ b/Npgmq.sln
@@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\build.yml = .github\workflows\build.yml
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Npgmq.Example", "Npgmq.Example\Npgmq.Example.csproj", "{60A266EF-6EFA-42B0-B592-C0C50BC32C7C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -29,6 +31,10 @@ Global
{27C187EE-9298-452F-9FA7-6DF8FC381095}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27C187EE-9298-452F-9FA7-6DF8FC381095}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27C187EE-9298-452F-9FA7-6DF8FC381095}.Release|Any CPU.Build.0 = Release|Any CPU
+ {60A266EF-6EFA-42B0-B592-C0C50BC32C7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {60A266EF-6EFA-42B0-B592-C0C50BC32C7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {60A266EF-6EFA-42B0-B592-C0C50BC32C7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {60A266EF-6EFA-42B0-B592-C0C50BC32C7C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8C37002D-05C6-4B1F-B4FC-C2F45C5E5328} = {023319FF-914F-42F7-AE34-3BA9CF91DAEE}
diff --git a/Npgmq/Npgmq.csproj b/Npgmq/Npgmq.csproj
index ad5b4ff..08ec567 100644
--- a/Npgmq/Npgmq.csproj
+++ b/Npgmq/Npgmq.csproj
@@ -18,7 +18,7 @@
-
+
diff --git a/README.md b/README.md
index 8724b99..8dd95d2 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,8 @@ using Npgmq;
var npgmq = new NpgmqClient("");
+await npgmq.InitAsync();
+
await npgmq.CreateQueueAsync("my_queue");
var msgId = await npgmq.SendAsync("my_queue", new MyMessageType
@@ -35,7 +37,7 @@ var msg = await npgmq.ReadAsync("my_queue");
if (msg != null)
{
Console.WriteLine($"Read message with id {msg.MsgId}: Foo = {msg.Message?.Foo}, Bar = {msg.Message?.Bar}");
- await npgmq.ArchiveAsync("my_queue", msg!.MsgId);
+ await npgmq.ArchiveAsync("my_queue", msg.MsgId);
}
```
@@ -59,7 +61,7 @@ var msg = await npgmq.ReadAsync("my_queue");
if (msg != null)
{
Console.WriteLine($"Read message with id {msg.MsgId}: {msg.Message}");
- await npgmq.ArchiveAsync("my_queue", msg!.MsgId);
+ await npgmq.ArchiveAsync("my_queue", msg.MsgId);
}
```