1 00:00:01,210 --> 00:00:03,550 We've got all that graceful shutdown stuff but together. 2 00:00:03,550 --> 00:00:07,360 But now the big question is inside of our new ticket root handler. 3 00:00:07,420 --> 00:00:10,630 Are we actually successfully publishing an event. 4 00:00:10,670 --> 00:00:15,150 So in this video we're going to figure out how to test this so to do so well. 5 00:00:15,320 --> 00:00:21,020 You might recall for the millionth time that inside of our Nats Tesla project we had that listener put 6 00:00:21,020 --> 00:00:29,000 together and that listener was listening for any event of type or on the subject on the channel of where 7 00:00:29,000 --> 00:00:29,590 is it. 8 00:00:29,630 --> 00:00:31,400 Ticket create it right here. 9 00:00:31,400 --> 00:00:35,750 So we actually already have a listener inside this other project that can listen for the event subject 10 00:00:35,750 --> 00:00:37,420 that we are emitting. 11 00:00:37,520 --> 00:00:41,110 Let's try to run our listener from this Nats test project again. 12 00:00:41,240 --> 00:00:46,070 Well then attempt to create a ticket using postman and then verify that we get a console log from this 13 00:00:46,070 --> 00:00:47,740 listener to the set. 14 00:00:47,750 --> 00:00:48,800 All this stuff up. 15 00:00:48,800 --> 00:00:51,100 I can go over to my terminal. 16 00:00:51,320 --> 00:00:54,620 I'll do a cube Seitel get pods. 17 00:00:54,620 --> 00:00:58,760 I can once again find my Nats deployment and I'm gonna set up port forwarding for it once again. 18 00:00:59,570 --> 00:01:07,960 They'll do a cube Seitel port forward based in that pod name and we want to bind 4 2 2 2 colon 4 2 2 19 00:01:07,960 --> 00:01:12,880 2 then in another terminal window. 20 00:01:13,080 --> 00:01:16,920 I'm gonna go back to my Nats test directory once again inside there. 21 00:01:16,920 --> 00:01:23,120 We'll do it NPM run listen and then we should see a listener connected to at Nats. 22 00:01:23,370 --> 00:01:25,990 Now all we have to do is attempt to actually create a ticket. 23 00:01:25,990 --> 00:01:30,980 So for that we're going to pull a postman open once again now in order to create a ticket. 24 00:01:30,990 --> 00:01:33,230 Remember you need to be authenticated. 25 00:01:33,360 --> 00:01:38,730 So you might very quickly want to make a get request to ticketing Dev API users current users and make 26 00:01:38,730 --> 00:01:39,870 sure that you are all signed in. 27 00:01:40,260 --> 00:01:44,760 If you're not signed in either make a post request to sign in with some valid credentials or make a 28 00:01:44,760 --> 00:01:51,500 post request to sign up then verify that you are signed in and then finally we'll go ahead and try to 29 00:01:51,500 --> 00:01:56,370 create a ticket and we can do that by making a post request to an API such tickets. 30 00:01:56,440 --> 00:01:58,430 We'll make sure that we've got a body inside of here. 31 00:01:58,460 --> 00:02:02,940 Make sure the thing is set to Jason title and price are required. 32 00:02:03,350 --> 00:02:06,580 So I can send this off and there's my ticket. 33 00:02:08,090 --> 00:02:13,180 So now we should need to go back over to our terminal and inside the listener window we should see that 34 00:02:13,180 --> 00:02:16,950 we receive some data on the subject ticket created. 35 00:02:16,990 --> 00:02:18,850 Here's the raw event data. 36 00:02:19,030 --> 00:02:23,820 We've got the idea the title the price and the idea the user who created this. 37 00:02:23,860 --> 00:02:27,990 Yeah it works it works well hopefully it works for you as well. 38 00:02:28,210 --> 00:02:32,710 If you do not see anything here the very first thing to check make sure you've got some consistent subject 39 00:02:32,710 --> 00:02:39,160 names based upon this whole typescript stuff that we put together all the subject names should be consistent. 40 00:02:39,160 --> 00:02:43,120 So do you go backward to the ticket created listener we had created inside of Nats test make sure you 41 00:02:43,120 --> 00:02:49,630 get a subject inside their ticket created if that name is different at all. 42 00:02:49,630 --> 00:02:53,230 Obviously the subject being different you're gonna be listening to different channel and so it's not 43 00:02:53,230 --> 00:02:55,650 going to work as expected all right. 44 00:02:55,660 --> 00:02:59,980 So it looks like we are able to publish we are able to listen. 45 00:02:59,980 --> 00:03:00,950 Awesome. 46 00:03:01,090 --> 00:03:06,890 Now the very last thing we really have to do inside of our ticket service we need to make sure that 47 00:03:06,910 --> 00:03:09,120 we also emit a very similar event. 48 00:03:09,160 --> 00:03:15,340 Anytime someone updates a ticket as well so we're gonna go into our new route handler essentially more 49 00:03:15,340 --> 00:03:20,600 or less just copy paste this code over to the update row handler and that should pretty much be it. 50 00:03:20,690 --> 00:03:20,920 OK. 51 00:03:20,950 --> 00:03:21,800 So quick pause right here. 52 00:03:21,820 --> 00:03:23,540 Take care of this in just a moment.