The last thing we do around our two listeners is make sure that we actually create an instance about
them when we create the instance remember we do we have to provide an instance of the Nats string server
client once we create the instance we're then going to call the listener method on those instances.
If you don't remember any of this no problem we can always do a command click on the less listener definition.
This thing will tell you that the constructor expects to receive an instance of the stand client or
the node assuming server client and it's the listen function in particular that's gonna make sure that
we actually start listening for incoming traffic.
So right now we're going to create our instances and start listening for these events from inside of
the index dot s file inside of our route s our C directory I'll open up index t s member inside this
file we create our Nats wrapper and we get access to the Nats client inside there.
So right after we go through all that Nats initialization stuff right after that is probably a good
time to start listening for incoming events so at the very top let's import those two listeners that
we just created.
I'm going to import ticket created listener
from events listeners ticket created listener and then something very similar.
Ticket.
Updated listener from events listeners to get updated.
Listener
All right.
Then down after we create all that Nats rapper stuff.
Let's go ahead and create a new instance of ticket created.
Listener will pass in our Nats rapper client and they will tell this thing to start listening for traffic.
Same thing with ticket.
Updated as well so new ticket.
Updated listener Nats rapper client and call listen and that should be it.
Let's now save this file and then going to go over to a scaffold which is still running inside my terminal
and hopefully you should see everything boot up without any errors.
If you don't see anything at all remember you can always restart scaffold but hopefully you do see something
that says that we're connected to Nats connected Mongo TB and so on now to do a manual test.
These listeners we could try to trigger the ticket updated and the ticket publish or ticket related
events and we can do that by simply manually creating a ticket using postman once we go through that
once we create manually a ticket and updated.
We should start to see some logging console logs to say that we have a listener inside the order service
that has received those events.
So let's start to do that little manual test in the next video.