1 00:00:00,780 --> 00:00:03,710 ‫Now let's talk about a delay queue. 2 00:00:03,710 --> 00:00:07,590 ‫So a delay queue is to delay messages so that consumers 3 00:00:07,590 --> 00:00:09,560 ‫don't see them immediately. 4 00:00:09,560 --> 00:00:13,050 ‫And this can be a delay of up to 15 minutes. 5 00:00:13,050 --> 00:00:16,140 ‫By default, the delay parameter is zero seconds. 6 00:00:16,140 --> 00:00:17,900 ‫That means that as soon as you send the message 7 00:00:17,900 --> 00:00:20,730 ‫into an SQS queue, the message will be available right away 8 00:00:20,730 --> 00:00:24,090 ‫to be read but you can set a default at the queue level 9 00:00:24,090 --> 00:00:27,030 ‫to say all the messages should be delayed by X number 10 00:00:27,030 --> 00:00:30,150 ‫of seconds or every time you send a message 11 00:00:30,150 --> 00:00:32,530 ‫you can set a per-message delay 12 00:00:32,530 --> 00:00:35,730 ‫if you wanted to using the DelaySeconds parameter. 13 00:00:35,730 --> 00:00:36,930 ‫So we have a queue. 14 00:00:36,930 --> 00:00:39,070 ‫Our producer will send a message to that queue 15 00:00:39,070 --> 00:00:41,220 ‫and the queue, for example, has a default value 16 00:00:41,220 --> 00:00:43,280 ‫for how long that message should be delayed. 17 00:00:43,280 --> 00:00:44,960 ‫And so maybe it's like 30 seconds. 18 00:00:44,960 --> 00:00:48,010 ‫And so after 30 seconds, then when a consumer polls 19 00:00:48,010 --> 00:00:50,020 ‫for messages, it will see that message 20 00:00:50,020 --> 00:00:51,800 ‫and receive it successfully. 21 00:00:51,800 --> 00:00:53,710 ‫So let's go into the console to see 22 00:00:53,710 --> 00:00:55,200 ‫how that works in practice. 23 00:00:55,200 --> 00:00:58,190 ‫So back in SQS, I'm going to create a queue 24 00:00:58,190 --> 00:01:01,180 ‫and I will call this one DelayQueue. 25 00:01:01,180 --> 00:01:03,780 ‫And as we can see here, we have a new setting 26 00:01:03,780 --> 00:01:05,440 ‫called delivery delay. 27 00:01:05,440 --> 00:01:08,550 ‫And so by default, it is zero seconds but we can set it 28 00:01:08,550 --> 00:01:10,410 ‫all the way to 15 minutes. 29 00:01:10,410 --> 00:01:13,100 ‫So I'm just going to set this to 10 seconds 30 00:01:13,100 --> 00:01:15,640 ‫so that messages will wait 10 seconds 31 00:01:15,640 --> 00:01:18,260 ‫before being read by a consumer. 32 00:01:18,260 --> 00:01:21,220 ‫Okay, the rest will be standard so we'll just go ahead 33 00:01:21,220 --> 00:01:23,140 ‫and click on Create queue. 34 00:01:23,140 --> 00:01:24,480 ‫Now my delay queue is created. 35 00:01:24,480 --> 00:01:27,060 ‫I will go ahead and send and receive messages. 36 00:01:27,060 --> 00:01:30,833 ‫And let's enter a random message. 37 00:01:31,830 --> 00:01:33,930 ‫Now, as you can see, by default, the deliver delay 38 00:01:33,930 --> 00:01:36,080 ‫has been created into the console 39 00:01:36,080 --> 00:01:38,750 ‫and it says 10 seconds but we can override it. 40 00:01:38,750 --> 00:01:41,880 ‫For example, you could say 30 or we could say zero 41 00:01:41,880 --> 00:01:44,530 ‫or maybe longer but we'll leave it as a default 42 00:01:44,530 --> 00:01:46,030 ‫of 10 seconds. 43 00:01:46,030 --> 00:01:48,930 ‫So I'm going to start polling for messages. 44 00:01:48,930 --> 00:01:51,370 ‫And as you can see, no messages are received. 45 00:01:51,370 --> 00:01:54,160 ‫And I'm going to send a message right now. 46 00:01:54,160 --> 00:01:55,550 ‫And we have to wait 10 seconds. 47 00:01:55,550 --> 00:02:00,500 ‫One, two, three, four, five, six, seven, eight, nine, 10. 48 00:02:00,500 --> 00:02:03,580 ‫And hopefully by now the message should appear 49 00:02:03,580 --> 00:02:04,413 ‫in my consumer. 50 00:02:04,413 --> 00:02:06,420 ‫And here it is. It's been 10 seconds. 51 00:02:06,420 --> 00:02:09,600 ‫And so, as you can see, there was a delay between the send 52 00:02:09,600 --> 00:02:11,950 ‫and the actual delivery of that message. 53 00:02:11,950 --> 00:02:13,840 ‫And for some use cases, this may be something 54 00:02:13,840 --> 00:02:16,970 ‫that you want and that's something that may be desirable. 55 00:02:16,970 --> 00:02:20,570 ‫But as a certified AWS person, you should know 56 00:02:20,570 --> 00:02:22,510 ‫that this functionality exists. 57 00:02:22,510 --> 00:02:25,290 ‫So that's it, very short demo but I hope that was helpful. 58 00:02:25,290 --> 00:02:27,890 ‫And I will see you in the next lecture.