From 607d9716d66d059190f16aa31f1ec34aac25e6b2 Mon Sep 17 00:00:00 2001 From: Brian Pursley Date: Mon, 1 Jul 2024 11:59:47 -0400 Subject: [PATCH] Update example application --- Npgmq.Example/Program.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Npgmq.Example/Program.cs b/Npgmq.Example/Program.cs index d26d62d..d0166fe 100644 --- a/Npgmq.Example/Program.cs +++ b/Npgmq.Example/Program.cs @@ -38,7 +38,7 @@ await connection.OpenAsync(); var npgmq = new NpgmqClient(connection); - await using (var tx = connection.BeginTransaction()) + await using (var tx = await connection.BeginTransactionAsync()) { var msgId = await npgmq.SendAsync("example_queue", new MyMessageType { @@ -46,6 +46,12 @@ Bar = 2 }); Console.WriteLine($"Sent message with id {msgId}"); + msgId = await npgmq.SendAsync("example_queue", new MyMessageType + { + Foo = "Connection object test", + Bar = 3 + }); + Console.WriteLine($"Sent message with id {msgId}"); await tx.CommitAsync(); } @@ -56,6 +62,12 @@ Console.WriteLine($"Read message with id {msg.MsgId}: Foo = {msg.Message?.Foo}, Bar = {msg.Message?.Bar}"); await npgmq.ArchiveAsync("example_queue", msg.MsgId); } + 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