We've now got our two listeners put together.
We're not quite done with them just yet.
Remember we still have to create an instance of them and tell them to start listening for incoming events
whenever our application for starts up.
So we've been doing that inside of our index t s file.
Let's do that again right now inside the index dot t s file at the very top.
I'm going to import the two listeners we just created.
That is order canceled.
Listener we're gonna get that from events listeners.
Order canceled.
Listener
and then our order greeted listener from events listeners.
Order created listener
then.
Right after we create our Nats rapper though all this Nats rap related stuff right after all that we'll
create an instance about those listeners will pass on the Nats rapper.
And don't forget we also have to call that listen method.
So do a new order created listener asked and that's rapper Doc client and then call us in on that and
then same thing for order canceled
and there we go.
Now this is going to be a really fun to save and see it start to run.
Remember we have been creating a couple of different orders behind the scenes in the last couple of
sections and whatnot.
So every time we create an order every time we canceled it all those different events have been getting
saved by our Nat streaming server assuming of course we have not restarted that Nat string server recently
and dumped all those different events.
So as soon as we save this file this service is going to restart that's going to create a subscription
to listen for all the events on the order created and the order canceled channels were we're going to
start to receive all the events we have missed out on over time.
So the instant that everything restarts we should very quickly start to see the expiration service starting
to backfill all the relevant data.
And again this is what really makes the idea of bringing up some service in the future possible and
having it rather quickly get all the relevant data that it needs by listening to all the events that
had previously been published.
Let's give this a shot.
Going to save the file and go back over to scaffold OK.
So I got my change right there.
And then in my case it looks like I restarted that out streaming server right before this video or actually
earlier today.
So I've not actually not created any order since then which is why I see nothing right here.
But hopefully if you did not recently restart assuming server or your entire cluster then you should
see some number of events getting processed.
That's in theory.
So to really make sure this thing works we should probably at least try to create one order and make
sure that the event gets processed by the payment service as usual to create an order we will open up
postman gonna make sure that I am authenticated Yep looks like I'm authenticated and I'll try to create
a ticket and then in order for that ticket we'll make a post request to create a ticket.
There's my ticket I.D. I'm going to copy it and I still have a tab open right here for a post request
to orders to create a new order.
I'm going to paste in that ticket I.D. send it off and if I put back over I should see a whole bunch
of stuff here.
I see on the expiration service may not expiration about payments.
There it is right there.
Message received.
Order created to the payment service.
So it looks like it probably worked as expected.
If we wait about the 60 seconds or so we will eventually also see the payment service receive another
event.
It'll be the order canceled event.
And so again that should be about 60 seconds or so.
So I'd encourage you to maybe just wait for that thing to show up just to confirm.
Yep I got that event coming across.
Well that's pretty much it for the orders side of our payment service so you can start to take a look
at how he handled payments in the next video.