Not going to start to work on the implementation of the on message function.
Let's first begin by getting a quick reminder of what we really need to do with a ticket created event
inside of our order service.
All right so you might recall looking at this diagram right here.
So we've got the ticket created event coming to order service.
The reason we are listening for this event inside of order service is so we can take the information
about this ticket that was just created and save it in a local tickets collection.
This is a classic example of data replication between different services.
We are saving this information about this ticket so that when the order service needs to know some details
about a ticket it does not have to do synchronous communication over to the ticket service to learn
about the different tickets that are are available.
So all we really need to do here is pull off some information about the ticket that was just created
and save it to our local tickets collection.
That's it.
Back inside of our Ed we'll find the on message function.
We're going to take a look at that data object right there.
The only properties we really want to persist inside of our order service is title and price.
And you might recall that by looking at our ticket model inside the order service again the only thing
we really care about right now is tile and price so we're going to pull off title and price from data
or then use that to build a new ticket
and then save it.
So we'll do it in a weight ticket not save because we are using the awake keyword.
Let's make sure we mark the enclosing function as async
and then assuming that all these steps go as expected and then we don't have any air we're then going
to want to act that message.
Remember when we act the message that tells Natsumi server that we have processed this thing and we
are good to go.
So at the very bottom we will do a message dot EQ like so well that is pretty much it for our first
on message function pretty straightforward.
Now unfortunately.
Well you know how life is.
Turns out that even though this looks really simple and it looks like everything will work as expected.
We've got some big issues inside of here.
So let's take a quick pause right now.
When we come back the next video I want to mention the first big issue that we're going to run into
if we continue with this implementation that we see currently.