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 })); }
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 })); }
public async Task GetQueueAttributesAsync(CreateQueueOptions value) { var rsmq = new Rsmq(); await rsmq.CreateQueueAsync(value); var attributes = await rsmq.GetQueueAttributesAsync(new GetQueueAttributesOptions { QueueName = value.QueueName }); Assert.AreEqual(attributes.Delay, value.Delay); Assert.AreEqual(attributes.MaxSize, value.MaxSize); Assert.AreEqual(attributes.VisibilityTimer, value.VisibilityTimer); Assert.AreEqual(0, attributes.TotalSent); await rsmq.SendMessageAsync(new SendMessageOptions { QueueName = value.QueueName, Message = "Halo" }); attributes = await rsmq.GetQueueAttributesAsync(new GetQueueAttributesOptions { QueueName = value.QueueName }); Assert.AreEqual(1, attributes.TotalSent); }