In this video we're going to get a quick reminder on how we create a listener you might recall that
inside of our common module and the SRT directory in the events folder we had created that base listener
class.
This was an abstract class and so we're going to extend this to build out different classes inside of
each of our services that are going to listen for very specific events when we extend this listener.
We're going to make sure we provide a event type as the generic type.
And then inside of the child class we're also going to be required to define a subject such can be subject
we want to listen to on that string server a Q Group name and we'll get a reminder on what that's about
really quickly.
And then finally the on message function the on message function is what's going to actually receive
an event that's we're going to implement some amount of business logic.
The first argument is going to be the data inside the event and the second argument will be a message
and we'll get a reminder on what that message is in a little bit.
ASM The other thing I want to remind you about is that when we create an instance of a listener we have
to provide a Nats client to it when we create an instance of a listener and provide the Nats client
that doesn't actually start the thing up listening.
Instead we have to call the listener method which we have defined down here.
This is what is going to actually tell the client to start to subscribe or create a subscription and
listen for events on a very particular subject or channel then whenever we receive a message that is
when we were going to actually call the on message function so in total in order to create a listener
we're going to create a new file inside of our different services.
It's going to extend this base listener class we're going to plug in at the event type 1 to listen for
and then define a couple of different properties inside of it.
And that's pretty much it.
Now as a reminder the first listener we're gonna put together is give me a listening for the ticket
created event and we're going to implement that inside of our order service.
Let's take a quick pause right here and then start to implement this first listener in the next video.