1
00:00:00,350 --> 00:00:01,330
So let's talk about

2
00:00:01,330 --> 00:00:03,830
the other kind of queues available in SQS

3
00:00:03,830 --> 00:00:07,200
called the Amazon SQS FIFO Queues.

4
00:00:07,200 --> 00:00:09,800
FIFO means first in first out.

5
00:00:09,800 --> 00:00:12,100
What this means is that the messages will be ordered

6
00:00:12,100 --> 00:00:14,710
in the queue and the first message to arrive in the queue

7
00:00:14,710 --> 00:00:17,080
will be the first message to leave the queue.

8
00:00:17,080 --> 00:00:20,000
So this is more ordering guarantee that we can get

9
00:00:20,000 --> 00:00:21,850
from a standard queue.

10
00:00:21,850 --> 00:00:23,720
So let's take an example of a producer

11
00:00:23,720 --> 00:00:25,920
sending messages into your SQS queue,

12
00:00:25,920 --> 00:00:27,460
the first message, then the second,

13
00:00:27,460 --> 00:00:29,210
the third and the fourth.

14
00:00:29,210 --> 00:00:31,540
And because we have an SQS FIFO queue,

15
00:00:31,540 --> 00:00:33,700
then the consumer will pull the messages

16
00:00:33,700 --> 00:00:36,920
from the SQS FIFO queue and receive the messages

17
00:00:36,920 --> 00:00:39,460
in the exact same order.

18
00:00:39,460 --> 00:00:42,850
Now, because we have such a constraint

19
00:00:42,850 --> 00:00:45,270
and guarantee about ordering,

20
00:00:45,270 --> 00:00:48,540
this SQS queue has limited throughput.

21
00:00:48,540 --> 00:00:52,070
So you get 300 messages per second without batching.

22
00:00:52,070 --> 00:00:54,550
Or if you send batches of messages,

23
00:00:54,550 --> 00:00:59,310
you can get a throughput of up to 3,000 messages per second.

24
00:00:59,310 --> 00:01:00,500
But thanks to FIFO queue,

25
00:01:00,500 --> 00:01:02,370
we get more guarantees and more constraints.

26
00:01:02,370 --> 00:01:05,880
So we have exactly-once send capability

27
00:01:05,880 --> 00:01:08,910
by a feature that allows SQS FIFO queue

28
00:01:08,910 --> 00:01:10,450
to remove duplicates.

29
00:01:10,450 --> 00:01:13,630
And we also know that the messages will be processed

30
00:01:13,630 --> 00:01:15,320
in order by the consumer.

31
00:01:15,320 --> 00:01:17,440
So FIFO queue is something you should see

32
00:01:17,440 --> 00:01:18,810
whenever you have decoupling,

33
00:01:18,810 --> 00:01:22,280
but also the need to maintain the ordering of messages,

34
00:01:22,280 --> 00:01:24,700
and also make sure that you are

35
00:01:24,700 --> 00:01:27,270
on this throughput's constraints

36
00:01:27,270 --> 00:01:31,370
that you are not sending too many messages into SQS, okay?

37
00:01:31,370 --> 00:01:34,290
So let's go ahead and create our first FIFO queue.

38
00:01:34,290 --> 00:01:36,240
So let's go and create a queue

39
00:01:36,240 --> 00:01:38,100
and I will create a FIFO queue.

40
00:01:38,100 --> 00:01:40,570
So as you can see, it's first in first out delivery

41
00:01:40,570 --> 00:01:43,370
and the message ordering is preserved.

42
00:01:43,370 --> 00:01:48,370
Okay, so I will name it demoqueue.fifo

43
00:01:48,400 --> 00:01:51,990
and you have to end it with .fifo.

44
00:01:51,990 --> 00:01:55,190
Otherwise, you will not have the ability

45
00:01:55,190 --> 00:01:56,330
to create this queue.

46
00:01:56,330 --> 00:01:58,460
It has to end with .fifo.

47
00:01:58,460 --> 00:01:59,670
Now, if we look at the configuration,

48
00:01:59,670 --> 00:02:01,510
it looks very similar to before,

49
00:02:01,510 --> 00:02:02,840
but we have one more setting

50
00:02:02,840 --> 00:02:04,700
called content-based deduplication.

51
00:02:04,700 --> 00:02:07,180
This is to deduplicate the messages

52
00:02:07,180 --> 00:02:09,139
if the same is sent twice

53
00:02:09,139 --> 00:02:12,340
in a very small five-minute window.

54
00:02:12,340 --> 00:02:14,270
Access policy will be left the same.

55
00:02:14,270 --> 00:02:16,660
Encryption and so on will be left the same.

56
00:02:16,660 --> 00:02:18,270
So I'll create this queue.

57
00:02:18,270 --> 00:02:22,290
And now if I go to send and receive messages,

58
00:02:22,290 --> 00:02:24,280
we can have a look at the message body.

59
00:02:24,280 --> 00:02:27,870
I can say, Hello World 1.

60
00:02:27,870 --> 00:02:30,920
And then I will have to specify a message group ID.

61
00:02:30,920 --> 00:02:31,880
I'll call this one demo

62
00:02:31,880 --> 00:02:34,270
and we'll use the same message group ID all along this demo.

63
00:02:34,270 --> 00:02:37,740
So demo is sent and a deduplication ID,

64
00:02:37,740 --> 00:02:40,220
excuse me, I will say it's my message number one,

65
00:02:40,220 --> 00:02:41,470
so I'll say ID one.

66
00:02:41,470 --> 00:02:42,630
Send this message.

67
00:02:42,630 --> 00:02:45,420
I'll do Hello World 2, the same message group ID,

68
00:02:45,420 --> 00:02:47,563
and I will say deduplication two.

69
00:02:48,780 --> 00:02:51,630
And then message a third one

70
00:02:51,630 --> 00:02:54,550
and I will say three in here

71
00:02:54,550 --> 00:02:58,500
and finally the fourth one and I will say four.

72
00:02:58,500 --> 00:03:01,100
Okay, so now the messages have been sent

73
00:03:01,100 --> 00:03:02,700
and they're ready to be received.

74
00:03:02,700 --> 00:03:04,510
And so we have four messages available.

75
00:03:04,510 --> 00:03:08,250
And if I pull four messages, we look at all the messages.

76
00:03:08,250 --> 00:03:12,270
And if I look at this one, it's actually in the wrong order.

77
00:03:12,270 --> 00:03:14,390
So if I look at the bottom one, which is the first one,

78
00:03:14,390 --> 00:03:15,880
it says, Hello World 1.

79
00:03:15,880 --> 00:03:19,350
Then if I look at the second message, Hello World 2.

80
00:03:19,350 --> 00:03:22,130
The third message I have Hello World 3.

81
00:03:22,130 --> 00:03:25,120
And the fourth message I will have Hello World 4.

82
00:03:25,120 --> 00:03:28,870
So this is a guarantee that you get thanks to FIFO queues.

83
00:03:28,870 --> 00:03:31,830
Then you go ahead and delete these messages and you're done.

84
00:03:31,830 --> 00:03:32,663
So that's it.

85
00:03:32,663 --> 00:03:33,620
I hope that was helpful.

86
00:03:33,620 --> 00:03:35,570
And I will see you in the next lecture.

