1 00:00:01,120 --> 00:00:04,780 In the last video we put together some sync code inside of our query. 2 00:00:04,780 --> 00:00:09,490 Before we test this out we did try to make use of axial sin here but unfortunately our query service 3 00:00:09,490 --> 00:00:11,730 does not yet have axles installed. 4 00:00:11,770 --> 00:00:16,150 We haven't even required it into this index dot J as file so I got gonna go up to the very top of this 5 00:00:16,150 --> 00:00:16,980 file. 6 00:00:17,110 --> 00:00:24,260 I'm going to require in axioms I'll save this all then go back over to my terminal. 7 00:00:24,300 --> 00:00:30,870 I'm gonna find the terminal window that is running my memory service I'm going to stop that thing I'll 8 00:00:30,870 --> 00:00:38,450 install axles really quickly and they'll start that server backup OK. 9 00:00:38,500 --> 00:00:39,840 ALEX Good. 10 00:00:39,850 --> 00:00:43,890 So now we need to make sure that we can actually test this out effectively. 11 00:00:43,890 --> 00:00:47,940 So I'm going to just go ahead and stop that server even though we just started it up. 12 00:00:47,980 --> 00:00:50,490 So now we do not have any access to query. 13 00:00:50,500 --> 00:00:57,280 It just doesn't exist but hopefully we can try to create some posts comments and whatever else those 14 00:00:57,280 --> 00:01:02,980 events will be cached or stored by our event bus and then as soon as we launch query hopefully query 15 00:01:02,980 --> 00:01:07,360 should be precinct and get all the different events that it has missed over time. 16 00:01:07,360 --> 00:01:11,040 Let's try this out making sure that the query service is not running. 17 00:01:11,140 --> 00:01:15,330 I'm going to go over to my browser I'm gonna refresh the page. 18 00:01:15,600 --> 00:01:19,890 You'll notice I've gotten error inside my console right now and that is to be expected because the query 19 00:01:19,890 --> 00:01:21,150 service does not exist. 20 00:01:21,150 --> 00:01:26,230 Right now it's not running at all but I should be able to create a post so I'll go ahead and create 21 00:01:26,230 --> 00:01:34,100 a post something like new post and submit now in theory this post has been created and we've gone through 22 00:01:34,100 --> 00:01:38,280 that entire process of storing it on the post service and so on. 23 00:01:38,390 --> 00:01:43,400 If I refresh right now I get another error again because the query server is done doesn't exist. 24 00:01:43,420 --> 00:01:45,360 So now let's go back over to our terminal. 25 00:01:45,800 --> 00:01:50,900 We'll go ahead and launch the query service and as soon as we do so it should reach out to our event 26 00:01:50,900 --> 00:01:51,440 bus. 27 00:01:51,440 --> 00:01:53,780 You'll notice there are some errors here you could ignore them. 28 00:01:53,780 --> 00:01:58,660 It should reach out to our event bus and try to receive all the different events that it has missed. 29 00:01:58,940 --> 00:02:04,100 It's going to start up the query service and you'll notice right away its process in event of post created 30 00:02:04,190 --> 00:02:05,480 that's the event that it had missed. 31 00:02:06,230 --> 00:02:11,310 So if I now go back with the browser I can refresh and there's my post. 32 00:02:11,460 --> 00:02:12,770 Now they benefit to this approach. 33 00:02:12,780 --> 00:02:15,620 If I kill my query service once again. 34 00:02:15,630 --> 00:02:16,970 So now it's dead again. 35 00:02:17,010 --> 00:02:24,590 Now I can start to maybe create some comments I can say comment no one I can create a comment. 36 00:02:24,590 --> 00:02:28,910 Number two I can create even an invalid comment something with the word orange in it. 37 00:02:28,940 --> 00:02:31,160 Something is going to get rejected. 38 00:02:31,160 --> 00:02:35,900 Now if I refresh again once again I don't see anything because the query services down in the query 39 00:02:35,900 --> 00:02:38,430 service has completely missed all these different events. 40 00:02:38,510 --> 00:02:44,660 It hasn't seen any of the come and created any of the comment moderated or the common updated events. 41 00:02:44,660 --> 00:02:50,400 Now let's relaunch query and instantly it's going to process all those different events that it just 42 00:02:50,400 --> 00:02:51,920 missed out on. 43 00:02:51,930 --> 00:02:59,810 Now if I go back to the browser I can refresh looks like the C and taking just a moment chances are 44 00:02:59,810 --> 00:03:01,190 it's gonna refresh way faster for you. 45 00:03:01,190 --> 00:03:01,840 There we go. 46 00:03:01,910 --> 00:03:05,990 And now we can see that the query service is online and 100 percent up to date. 47 00:03:05,990 --> 00:03:11,250 We've got our post we've got those comments and the comment that was rejected as well. 48 00:03:11,260 --> 00:03:13,510 All right so you gotta admit that's pretty neat. 49 00:03:13,990 --> 00:03:19,540 So this 100 hundred percent really deals with this issue of a service being brought online at some point 50 00:03:19,540 --> 00:03:24,910 in time the future or possibly the case in which a service goes down for some very small period of time 51 00:03:25,150 --> 00:03:27,470 and misses out on a couple of that events. 52 00:03:27,760 --> 00:03:32,640 We're going to use this strategy very heavily as we start to work on our next application. 53 00:03:32,660 --> 00:03:37,340 Now if you see some issues with this approach and there are some problems inside of here without a doubt 54 00:03:37,670 --> 00:03:38,390 don't sweat it. 55 00:03:38,450 --> 00:03:43,370 There are corner cases and we are going to cover these corner cases particularly around the possibility 56 00:03:43,370 --> 00:03:45,090 of having like persistent data. 57 00:03:45,170 --> 00:03:49,100 Right now none of our data is persistent we store it inside of some in-memory data structure that's 58 00:03:49,100 --> 00:03:55,590 lost instantly whenever a service goes down but if we were using a database where we were storing these 59 00:03:55,590 --> 00:04:00,600 posts and comments inside of some database would say that query service you might be thinking Hey we'll 60 00:04:00,600 --> 00:04:04,760 get into some trouble here if we try to run the same event or process in the same event twice. 61 00:04:04,890 --> 00:04:07,200 Again if you're thinking that don't sweat it. 62 00:04:07,200 --> 00:04:10,160 There are solutions to it that we're going to implement in our next application. 63 00:04:10,850 --> 00:04:11,150 Okay. 64 00:04:11,190 --> 00:04:14,460 So this entire idea of sinking events looks like it's pretty handy. 65 00:04:14,460 --> 00:04:16,140 So pause right here continue in just a minute.