1 00:00:01,170 --> 00:00:02,910 Let's get started working on our first listener. 2 00:00:02,910 --> 00:00:05,700 It's going to be the ticket created listener. 3 00:00:05,700 --> 00:00:06,990 It's inside of my order service. 4 00:00:06,990 --> 00:00:13,180 I'll find the event's directory inside there I'll make a new folder of listeners and then inside of 5 00:00:13,180 --> 00:00:16,130 listeners I'll make a new file of ticket created. 6 00:00:16,180 --> 00:00:22,300 Listener Scott to us will then start to put some implementation together right away. 7 00:00:22,320 --> 00:00:25,220 We're going to end up with a couple of different import statements at the very top. 8 00:00:25,740 --> 00:00:28,380 So let's add in a couple of different imports. 9 00:00:28,380 --> 00:00:35,140 First we will get the message type from a node not streaming. 10 00:00:35,240 --> 00:00:44,280 I'm going to get my subjects you know by listener base class and the ticket created event all those 11 00:00:44,280 --> 00:00:48,510 from my common module. 12 00:00:48,610 --> 00:00:51,850 I'm also going to get my ticket model. 13 00:00:51,850 --> 00:00:58,860 So from my model's directory right here I'll get ticket from up to directories. 14 00:01:00,510 --> 00:01:01,140 Models 15 00:01:04,960 --> 00:01:08,220 and then I think that's probably all we need for right now. 16 00:01:09,140 --> 00:01:11,940 Let's start to put the actual implementation for this thing together. 17 00:01:11,970 --> 00:01:18,620 So first off we're going to export a class of ticket read and listener and very similar to what we're 18 00:01:18,620 --> 00:01:20,070 doing with our different publishers. 19 00:01:20,090 --> 00:01:24,860 We are going to be extending an abstract class and this case listener. 20 00:01:24,860 --> 00:01:29,300 And remember this is a generic which means we have to provide a type and the type we're going to stick 21 00:01:29,300 --> 00:01:31,760 in here is the type of event that we're going to listen for. 22 00:01:31,850 --> 00:01:39,260 Which is ticket created events Doyel plug in ticket created event like so well then see our class name 23 00:01:39,320 --> 00:01:42,950 light up and touch script is telling us that there are three different properties we have to implement 24 00:01:42,950 --> 00:01:48,350 inside of here all because we are extending that abstract class so we have to implement on message your 25 00:01:48,410 --> 00:01:50,350 group name and subject. 26 00:01:50,390 --> 00:01:54,530 Well first start off with subject to the right in the subject right here and we're going to use the 27 00:01:54,530 --> 00:01:57,160 exact same system that we use back on our publishers. 28 00:01:57,200 --> 00:02:02,420 We're going to define or declare the subject property and we're gonna give it the very specific type 29 00:02:02,420 --> 00:02:03,320 that this thing is gonna be. 30 00:02:03,650 --> 00:02:09,610 So we'll say subjects dot ticket created and then we're going to actually assign it a value. 31 00:02:09,680 --> 00:02:12,200 Those subjects dot ticket created. 32 00:02:12,200 --> 00:02:17,150 And remember this kind of two step process right here is to make sure that typescript enforces us to 33 00:02:17,240 --> 00:02:21,800 never be able to change that subject property at any point in time. 34 00:02:21,810 --> 00:02:24,860 Next up we're gonna define our Q Group Name so. 35 00:02:25,090 --> 00:02:31,410 Q Group name in this case is going to be our quarters service. 36 00:02:31,410 --> 00:02:35,060 And like I said I'll give you a reminder on what that Q Group Name is in just a moment. 37 00:02:36,960 --> 00:02:41,090 And then finally we'll define our on message function. 38 00:02:41,200 --> 00:02:42,930 So this is going to receive two arguments. 39 00:02:42,940 --> 00:02:45,320 First is going to be the data from inside of our event. 40 00:02:45,340 --> 00:02:52,020 And the second is gonna be the message from the note not streaming library so put in here data and that's 41 00:02:52,020 --> 00:02:58,310 going to be up type ticket related event at data and the second argument will be message and that would 42 00:02:58,310 --> 00:03:01,460 be up type message all right. 43 00:03:01,490 --> 00:03:05,720 So I apologize for kind of speeding through this and saying oh yeah we'll come back to this and we'll 44 00:03:05,720 --> 00:03:07,970 come back to this and this message thing and so on. 45 00:03:07,970 --> 00:03:11,600 But I really just wanted through this code together because this is going to be very similar to what 46 00:03:11,660 --> 00:03:16,010 all of our different listeners look like all of our different listeners are going to extend the listener 47 00:03:16,010 --> 00:03:21,770 base class have the event type plugged into it and then define a subject a Q Group name and then on 48 00:03:21,830 --> 00:03:26,600 message now that we've established this kind of as the blueprint that we're going to be copy pasting 49 00:03:26,600 --> 00:03:28,110 over and over and over again. 50 00:03:28,220 --> 00:03:29,180 Another quick pause right here. 51 00:03:29,180 --> 00:03:34,160 When we come back the next video we're going to get a reminder on what that Q Group Name is why we have 52 00:03:34,160 --> 00:03:36,290 this weird invitation for data right here. 53 00:03:36,410 --> 00:03:39,070 And a reminder on what this message thing is as well.