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 ChangeMessageVisibilityAsync() { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(new CreateQueueOptions { QueueName = Global.QueueName }); var msgId = await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = Global.QueueName, Message = "hello" }); await rsmq.ChangeMessageVisibilityAsync(new ChangeMessageVisibilityOptions { QueueName = Global.QueueName, Id = msgId, VisibilityTimer = 2 }); Assert.IsNull(await rsmq.ReceiveMessageAsync(new ReceiveMessageOptions { QueueName = Global.QueueName })); await Task.Delay(2500); Assert.IsNotNull(await rsmq.ReceiveMessageAsync(new ReceiveMessageOptions { QueueName = Global.QueueName })); }