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