1 00:00:00,800 --> 00:00:03,920 All of the initial setup for our expiration service is complete. 2 00:00:03,950 --> 00:00:09,020 So I can start to focus on the actual application logic we're going to implement this in kind of a top 3 00:00:09,020 --> 00:00:10,360 down approach. 4 00:00:10,370 --> 00:00:14,640 We're going to first focus on creating a listener to watch for the order created event. 5 00:00:14,690 --> 00:00:19,510 Well then make sure that we start to set up something with bold J.S. then eventually create our publisher 6 00:00:19,520 --> 00:00:21,260 for the expiration complete event. 7 00:00:22,100 --> 00:00:28,700 So let's first get started with the order created listener inside of my expiration service in the SLC 8 00:00:28,720 --> 00:00:29,340 directory. 9 00:00:29,350 --> 00:00:33,130 I'm gonna make a new folder called events inside. 10 00:00:33,130 --> 00:00:40,300 They're going to create a new folder of listeners and then inside of that I'll make a new file of order 11 00:00:41,450 --> 00:00:43,730 created listener dot t yes 12 00:00:47,300 --> 00:00:51,070 so this listener is going to be very similar to all the listeners we've put together before. 13 00:00:51,110 --> 00:00:56,720 We're gonna subclass our listener base class we're gonna set up the on message function and then run 14 00:00:56,720 --> 00:00:57,890 some business logic inside. 15 00:00:57,890 --> 00:00:59,620 They're pretty straightforward. 16 00:00:59,630 --> 00:01:04,170 We've gone through this several times so let's just get right to it. 17 00:01:04,200 --> 00:01:13,890 First off I'm going to get my listener base class from my coming module I'll then exports a new class 18 00:01:13,890 --> 00:01:16,590 called order created listener. 19 00:01:16,590 --> 00:01:18,720 That's going to be extending the listener 20 00:01:22,250 --> 00:01:24,540 and then we can pretty much allow touch script to guide us from there. 21 00:01:24,560 --> 00:01:27,030 Just in case you forgot how all this stuff comes together. 22 00:01:27,080 --> 00:01:29,880 So once again immediately we've really been through this. 23 00:01:29,910 --> 00:01:36,160 No we have to plug in the type of event that we want to listen for so long once you get the order created 24 00:01:36,180 --> 00:01:38,940 events plug it in as a generic type 25 00:01:42,010 --> 00:01:47,010 we will then be told that we have to supply on message cougar name and subject. 26 00:01:47,110 --> 00:01:52,920 Let's take your subject first so I'll get my subjects in enum and then say that subject is going to 27 00:01:52,920 --> 00:02:02,080 be up type subject stocks order created and its value will be subject stocks order created then our 28 00:02:02,100 --> 00:02:03,210 Q group name. 29 00:02:03,210 --> 00:02:07,920 Once again we will create a Q Group Name inside of a separate file just to avoid any typos. 30 00:02:07,920 --> 00:02:12,630 I don't really expect to have any other listeners but it's still nice to follow the same pattern inside 31 00:02:12,630 --> 00:02:13,850 the listeners directory. 32 00:02:13,880 --> 00:02:16,730 I'll make a new folder of Q Group Name that. 33 00:02:16,790 --> 00:02:21,220 Yes sorry I think I might I said folder meant they file a file of Q group name. 34 00:02:21,270 --> 00:02:31,420 Yes and then I will export concept you group name and we'll give this one a name of expiration service 35 00:02:35,360 --> 00:02:39,170 back over and the listener at the very top. 36 00:02:41,750 --> 00:02:43,760 Let's get our Q Group name 37 00:02:47,160 --> 00:02:52,510 from that file we just created assign it as a property to the class 38 00:02:57,180 --> 00:03:03,600 and then define our on message function as usual this thing is gonna receive two arguments so data that 39 00:03:03,600 --> 00:03:06,820 would be of type order created events specifically the data properties. 40 00:03:06,820 --> 00:03:10,120 So order created event at data 41 00:03:13,140 --> 00:03:20,800 and then our message which we have type message and that is coming from the node Nat streaming library 42 00:03:22,410 --> 00:03:22,650 okay. 43 00:03:22,650 --> 00:03:23,210 So good start. 44 00:03:25,180 --> 00:03:26,810 Well that is pretty much it. 45 00:03:26,830 --> 00:03:28,350 Or step number one right here. 46 00:03:28,360 --> 00:03:33,030 So from here on out we're going to start to focus on exactly how we work with James and how we're going 47 00:03:33,030 --> 00:03:36,640 to tell it to remind us to do something in 15 minutes. 48 00:03:36,640 --> 00:03:41,320 Let's start to get a deeper overview of what's going on with the ball ust library in the next video.