1 00:00:00,880 --> 00:00:04,720 The last thing we do around our two listeners is make sure that we actually create an instance about 2 00:00:04,720 --> 00:00:10,600 them when we create the instance remember we do we have to provide an instance of the Nats string server 3 00:00:10,600 --> 00:00:16,700 client once we create the instance we're then going to call the listener method on those instances. 4 00:00:16,700 --> 00:00:21,670 If you don't remember any of this no problem we can always do a command click on the less listener definition. 5 00:00:21,920 --> 00:00:26,180 This thing will tell you that the constructor expects to receive an instance of the stand client or 6 00:00:26,180 --> 00:00:30,910 the node assuming server client and it's the listen function in particular that's gonna make sure that 7 00:00:30,920 --> 00:00:32,620 we actually start listening for incoming traffic. 8 00:00:33,660 --> 00:00:39,120 So right now we're going to create our instances and start listening for these events from inside of 9 00:00:39,110 --> 00:00:47,120 the index dot s file inside of our route s our C directory I'll open up index t s member inside this 10 00:00:47,120 --> 00:00:52,570 file we create our Nats wrapper and we get access to the Nats client inside there. 11 00:00:52,640 --> 00:00:57,050 So right after we go through all that Nats initialization stuff right after that is probably a good 12 00:00:57,050 --> 00:01:02,780 time to start listening for incoming events so at the very top let's import those two listeners that 13 00:01:02,780 --> 00:01:03,990 we just created. 14 00:01:04,090 --> 00:01:07,100 I'm going to import ticket created listener 15 00:01:10,470 --> 00:01:20,380 from events listeners ticket created listener and then something very similar. 16 00:01:20,560 --> 00:01:21,080 Ticket. 17 00:01:21,220 --> 00:01:27,660 Updated listener from events listeners to get updated. 18 00:01:27,660 --> 00:01:28,110 Listener 19 00:01:30,970 --> 00:01:31,380 All right. 20 00:01:31,460 --> 00:01:34,350 Then down after we create all that Nats rapper stuff. 21 00:01:36,720 --> 00:01:39,690 Let's go ahead and create a new instance of ticket created. 22 00:01:39,750 --> 00:01:48,440 Listener will pass in our Nats rapper client and they will tell this thing to start listening for traffic. 23 00:01:48,450 --> 00:01:49,500 Same thing with ticket. 24 00:01:49,520 --> 00:01:51,420 Updated as well so new ticket. 25 00:01:51,550 --> 00:01:59,990 Updated listener Nats rapper client and call listen and that should be it. 26 00:02:00,040 --> 00:02:04,780 Let's now save this file and then going to go over to a scaffold which is still running inside my terminal 27 00:02:05,840 --> 00:02:08,810 and hopefully you should see everything boot up without any errors. 28 00:02:08,810 --> 00:02:13,220 If you don't see anything at all remember you can always restart scaffold but hopefully you do see something 29 00:02:13,220 --> 00:02:18,360 that says that we're connected to Nats connected Mongo TB and so on now to do a manual test. 30 00:02:18,380 --> 00:02:25,810 These listeners we could try to trigger the ticket updated and the ticket publish or ticket related 31 00:02:25,960 --> 00:02:31,950 events and we can do that by simply manually creating a ticket using postman once we go through that 32 00:02:31,950 --> 00:02:34,350 once we create manually a ticket and updated. 33 00:02:34,440 --> 00:02:39,480 We should start to see some logging console logs to say that we have a listener inside the order service 34 00:02:39,660 --> 00:02:41,210 that has received those events. 35 00:02:41,340 --> 00:02:44,040 So let's start to do that little manual test in the next video.