1 00:00:01,140 --> 00:00:03,480 The order against a listener is looking fantastic. 2 00:00:03,480 --> 00:00:07,470 Now to wrap up our ticket service just a couple more little steps. 3 00:00:07,470 --> 00:00:09,580 First off we have created two listeners now. 4 00:00:09,600 --> 00:00:11,820 So order canceled in order created. 5 00:00:11,820 --> 00:00:15,730 But at no point time do we actually start listening or incoming events. 6 00:00:15,750 --> 00:00:19,230 In other words in the actual application itself not in the test environment. 7 00:00:19,230 --> 00:00:22,770 Do we ever create an instance the listener and tell it to start listening. 8 00:00:22,770 --> 00:00:26,790 You might recall that back inside of our order service we wired all that stuff up and sidebar indexed 9 00:00:26,860 --> 00:00:27,950 yes file. 10 00:00:28,050 --> 00:00:29,660 We're going to do that here once again. 11 00:00:29,910 --> 00:00:33,100 Back inside my index dot test file at the very top. 12 00:00:33,120 --> 00:00:35,590 I'm going to import are two listeners. 13 00:00:35,840 --> 00:00:50,190 So order reader listener from events listeners order created I will also get my order a canceled listener 14 00:00:54,020 --> 00:00:56,350 from events listeners order canceled listener. 15 00:00:56,370 --> 00:00:59,230 While those are really long import statements. 16 00:00:59,260 --> 00:01:04,600 Now we're going to create an instance of both these and pass in the Nats wrapper client to both them 17 00:01:05,740 --> 00:01:06,770 it's scroll down a little bit. 18 00:01:08,000 --> 00:01:16,620 Right after all of our Nats connection stuff we will throw in a new order created listener will pass 19 00:01:16,620 --> 00:01:18,910 in At NATS rapper client. 20 00:01:19,200 --> 00:01:21,870 And remember just creating an instance is not enough. 21 00:01:22,200 --> 00:01:26,700 We've also got on there at the listen method miss the listen function that actually tells the listener 22 00:01:26,700 --> 00:01:28,330 to start listening for incoming events. 23 00:01:28,410 --> 00:01:29,770 So we need to make sure we call listen. 24 00:01:29,770 --> 00:01:34,770 On the very end will then repeat that for order canceled. 25 00:01:35,060 --> 00:01:38,160 Listener Nats rapper or client 26 00:01:42,980 --> 00:01:43,590 looks good. 27 00:01:46,110 --> 00:01:46,360 All right. 28 00:01:46,360 --> 00:01:51,340 There's just one last very small task we have take care of inside of our ticket service. 29 00:01:51,340 --> 00:01:56,170 So we've now got this entire ability through these two listeners to somehow lock down and ticket and 30 00:01:56,170 --> 00:01:57,900 then unlock it later on. 31 00:01:58,150 --> 00:02:02,830 But at no point do we actually implement any logic to prevent a user from editing a ticket that is currently 32 00:02:02,830 --> 00:02:04,150 locked down. 33 00:02:04,150 --> 00:02:10,040 So this should be a very small and simple change inside of our router file for the update route. 34 00:02:10,060 --> 00:02:13,690 We're just gonna make sure that if a ticket is locked down we're going to tell a user sorry you can't 35 00:02:13,750 --> 00:02:18,040 update this thing should be pretty easy and straightforward but I would like to write a test around 36 00:02:18,040 --> 00:02:18,940 it as well. 37 00:02:18,940 --> 00:02:21,370 So let's take a shot at this in just a moment.