We've got all that graceful shutdown stuff but together.
But now the big question is inside of our new ticket root handler.
Are we actually successfully publishing an event.
So in this video we're going to figure out how to test this so to do so well.
You might recall for the millionth time that inside of our Nats Tesla project we had that listener put
together and that listener was listening for any event of type or on the subject on the channel of where
is it.
Ticket create it right here.
So we actually already have a listener inside this other project that can listen for the event subject
that we are emitting.
Let's try to run our listener from this Nats test project again.
Well then attempt to create a ticket using postman and then verify that we get a console log from this
listener to the set.
All this stuff up.
I can go over to my terminal.
I'll do a cube Seitel get pods.
I can once again find my Nats deployment and I'm gonna set up port forwarding for it once again.
They'll do a cube Seitel port forward based in that pod name and we want to bind 4 2 2 2 colon 4 2 2
2 then in another terminal window.
I'm gonna go back to my Nats test directory once again inside there.
We'll do it NPM run listen and then we should see a listener connected to at Nats.
Now all we have to do is attempt to actually create a ticket.
So for that we're going to pull a postman open once again now in order to create a ticket.
Remember you need to be authenticated.
So you might very quickly want to make a get request to ticketing Dev API users current users and make
sure that you are all signed in.
If you're not signed in either make a post request to sign in with some valid credentials or make a
post request to sign up then verify that you are signed in and then finally we'll go ahead and try to
create a ticket and we can do that by making a post request to an API such tickets.
We'll make sure that we've got a body inside of here.
Make sure the thing is set to Jason title and price are required.
So I can send this off and there's my ticket.
So now we should need to go back over to our terminal and inside the listener window we should see that
we receive some data on the subject ticket created.
Here's the raw event data.
We've got the idea the title the price and the idea the user who created this.
Yeah it works it works well hopefully it works for you as well.
If you do not see anything here the very first thing to check make sure you've got some consistent subject
names based upon this whole typescript stuff that we put together all the subject names should be consistent.
So do you go backward to the ticket created listener we had created inside of Nats test make sure you
get a subject inside their ticket created if that name is different at all.
Obviously the subject being different you're gonna be listening to different channel and so it's not
going to work as expected all right.
So it looks like we are able to publish we are able to listen.
Awesome.
Now the very last thing we really have to do inside of our ticket service we need to make sure that
we also emit a very similar event.
Anytime someone updates a ticket as well so we're gonna go into our new route handler essentially more
or less just copy paste this code over to the update row handler and that should pretty much be it.
OK.
So quick pause right here.
Take care of this in just a moment.