All of the initial setup for our expiration service is complete.
So I can start to focus on the actual application logic we're going to implement this in kind of a top
down approach.
We're going to first focus on creating a listener to watch for the order created event.
Well then make sure that we start to set up something with bold J.S. then eventually create our publisher
for the expiration complete event.
So let's first get started with the order created listener inside of my expiration service in the SLC
directory.
I'm gonna make a new folder called events inside.
They're going to create a new folder of listeners and then inside of that I'll make a new file of order
created listener dot t yes
so this listener is going to be very similar to all the listeners we've put together before.
We're gonna subclass our listener base class we're gonna set up the on message function and then run
some business logic inside.
They're pretty straightforward.
We've gone through this several times so let's just get right to it.
First off I'm going to get my listener base class from my coming module I'll then exports a new class
called order created listener.
That's going to be extending the listener
and then we can pretty much allow touch script to guide us from there.
Just in case you forgot how all this stuff comes together.
So once again immediately we've really been through this.
No we have to plug in the type of event that we want to listen for so long once you get the order created
events plug it in as a generic type
we will then be told that we have to supply on message cougar name and subject.
Let's take your subject first so I'll get my subjects in enum and then say that subject is going to
be up type subject stocks order created and its value will be subject stocks order created then our
Q group name.
Once again we will create a Q Group Name inside of a separate file just to avoid any typos.
I don't really expect to have any other listeners but it's still nice to follow the same pattern inside
the listeners directory.
I'll make a new folder of Q Group Name that.
Yes sorry I think I might I said folder meant they file a file of Q group name.
Yes and then I will export concept you group name and we'll give this one a name of expiration service
back over and the listener at the very top.
Let's get our Q Group name
from that file we just created assign it as a property to the class
and then define our on message function as usual this thing is gonna receive two arguments so data that
would be of type order created events specifically the data properties.
So order created event at data
and then our message which we have type message and that is coming from the node Nat streaming library
okay.
So good start.
Well that is pretty much it.
Or step number one right here.
So from here on out we're going to start to focus on exactly how we work with James and how we're going
to tell it to remind us to do something in 15 minutes.
Let's start to get a deeper overview of what's going on with the ball ust library in the next video.