1 00:00:00,950 --> 00:00:03,110 We've now got our two listeners put together. 2 00:00:03,110 --> 00:00:04,820 We're not quite done with them just yet. 3 00:00:04,820 --> 00:00:09,080 Remember we still have to create an instance of them and tell them to start listening for incoming events 4 00:00:09,260 --> 00:00:11,180 whenever our application for starts up. 5 00:00:11,210 --> 00:00:13,620 So we've been doing that inside of our index t s file. 6 00:00:13,640 --> 00:00:17,840 Let's do that again right now inside the index dot t s file at the very top. 7 00:00:17,840 --> 00:00:20,600 I'm going to import the two listeners we just created. 8 00:00:20,600 --> 00:00:23,560 That is order canceled. 9 00:00:23,580 --> 00:00:27,940 Listener we're gonna get that from events listeners. 10 00:00:27,960 --> 00:00:29,440 Order canceled. 11 00:00:29,450 --> 00:00:29,850 Listener 12 00:00:33,090 --> 00:00:39,500 and then our order greeted listener from events listeners. 13 00:00:39,500 --> 00:00:40,510 Order created listener 14 00:00:43,680 --> 00:00:43,920 then. 15 00:00:43,950 --> 00:00:49,870 Right after we create our Nats rapper though all this Nats rap related stuff right after all that we'll 16 00:00:49,890 --> 00:00:52,850 create an instance about those listeners will pass on the Nats rapper. 17 00:00:52,860 --> 00:00:55,950 And don't forget we also have to call that listen method. 18 00:00:55,990 --> 00:01:05,900 So do a new order created listener asked and that's rapper Doc client and then call us in on that and 19 00:01:05,910 --> 00:01:07,320 then same thing for order canceled 20 00:01:13,180 --> 00:01:13,720 and there we go. 21 00:01:14,740 --> 00:01:18,260 Now this is going to be a really fun to save and see it start to run. 22 00:01:18,280 --> 00:01:22,930 Remember we have been creating a couple of different orders behind the scenes in the last couple of 23 00:01:22,930 --> 00:01:24,310 sections and whatnot. 24 00:01:24,460 --> 00:01:28,390 So every time we create an order every time we canceled it all those different events have been getting 25 00:01:28,390 --> 00:01:33,730 saved by our Nat streaming server assuming of course we have not restarted that Nat string server recently 26 00:01:33,940 --> 00:01:36,100 and dumped all those different events. 27 00:01:36,100 --> 00:01:41,400 So as soon as we save this file this service is going to restart that's going to create a subscription 28 00:01:41,400 --> 00:01:46,890 to listen for all the events on the order created and the order canceled channels were we're going to 29 00:01:46,890 --> 00:01:50,010 start to receive all the events we have missed out on over time. 30 00:01:50,130 --> 00:01:54,570 So the instant that everything restarts we should very quickly start to see the expiration service starting 31 00:01:54,570 --> 00:01:56,590 to backfill all the relevant data. 32 00:01:56,590 --> 00:02:01,230 And again this is what really makes the idea of bringing up some service in the future possible and 33 00:02:01,230 --> 00:02:06,000 having it rather quickly get all the relevant data that it needs by listening to all the events that 34 00:02:06,000 --> 00:02:08,260 had previously been published. 35 00:02:08,340 --> 00:02:09,290 Let's give this a shot. 36 00:02:09,310 --> 00:02:14,600 Going to save the file and go back over to scaffold OK. 37 00:02:14,760 --> 00:02:16,560 So I got my change right there. 38 00:02:17,050 --> 00:02:24,040 And then in my case it looks like I restarted that out streaming server right before this video or actually 39 00:02:24,070 --> 00:02:25,120 earlier today. 40 00:02:25,120 --> 00:02:29,170 So I've not actually not created any order since then which is why I see nothing right here. 41 00:02:29,260 --> 00:02:34,600 But hopefully if you did not recently restart assuming server or your entire cluster then you should 42 00:02:34,600 --> 00:02:36,710 see some number of events getting processed. 43 00:02:37,290 --> 00:02:38,420 That's in theory. 44 00:02:38,920 --> 00:02:43,120 So to really make sure this thing works we should probably at least try to create one order and make 45 00:02:43,120 --> 00:02:49,460 sure that the event gets processed by the payment service as usual to create an order we will open up 46 00:02:49,480 --> 00:02:58,450 postman gonna make sure that I am authenticated Yep looks like I'm authenticated and I'll try to create 47 00:02:58,510 --> 00:03:04,580 a ticket and then in order for that ticket we'll make a post request to create a ticket. 48 00:03:04,670 --> 00:03:09,810 There's my ticket I.D. I'm going to copy it and I still have a tab open right here for a post request 49 00:03:09,810 --> 00:03:11,600 to orders to create a new order. 50 00:03:11,820 --> 00:03:18,600 I'm going to paste in that ticket I.D. send it off and if I put back over I should see a whole bunch 51 00:03:18,600 --> 00:03:19,130 of stuff here. 52 00:03:19,140 --> 00:03:22,730 I see on the expiration service may not expiration about payments. 53 00:03:22,740 --> 00:03:23,640 There it is right there. 54 00:03:23,640 --> 00:03:24,490 Message received. 55 00:03:24,510 --> 00:03:26,820 Order created to the payment service. 56 00:03:26,820 --> 00:03:29,050 So it looks like it probably worked as expected. 57 00:03:30,530 --> 00:03:35,990 If we wait about the 60 seconds or so we will eventually also see the payment service receive another 58 00:03:35,990 --> 00:03:36,370 event. 59 00:03:36,380 --> 00:03:38,050 It'll be the order canceled event. 60 00:03:38,550 --> 00:03:40,900 And so again that should be about 60 seconds or so. 61 00:03:40,910 --> 00:03:44,210 So I'd encourage you to maybe just wait for that thing to show up just to confirm. 62 00:03:44,240 --> 00:03:46,970 Yep I got that event coming across. 63 00:03:47,000 --> 00:03:51,560 Well that's pretty much it for the orders side of our payment service so you can start to take a look 64 00:03:51,560 --> 00:03:53,420 at how he handled payments in the next video.