public async Task ReceiveMessageAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); var msgId1 = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello1" }); var msgId2 = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello2" }); var message1 = await rsmq.ReceiveMessageAsync(new ReceiveMessageOptions { QueueName = Global.QueueName }); var message2 = await rsmq.ReceiveMessageAsync(new ReceiveMessageOptions { QueueName = Global.QueueName }); Assert.NotNull(message1); Assert.NotNull(message2); Assert.AreEqual("hello1", message1.Message); Assert.AreEqual("hello2", message2.Message); Assert.AreEqual(msgId1, message1.Id); Assert.AreEqual(msgId2, message2.Id); Assert.AreEqual(1, await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = msgId1 })); Assert.AreEqual(1, await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = msgId2 })); }
public async Task DeleteMessageAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); var msgId = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello" }); Assert.AreEqual(1, await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = msgId })); Assert.Zero(await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = "0123456789abcdefghijklmnopqrstuv" })); }
public async Task PopMessageAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); var msgId = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello" }); var poppedMessage = await rsmq.PopMessageAsync(new PopMessageOptions { QueueName = Global.QueueName }); Assert.AreEqual(msgId, poppedMessage.Id); Assert.Zero(await rsmq.DeleteMessageAsync(new DeleteMessageOptions { QueueName = Global.QueueName, Id = msgId })); }