1 00:00:01,230 --> 00:00:04,470 Not going to start to work on the implementation of the on message function. 2 00:00:04,480 --> 00:00:09,190 Let's first begin by getting a quick reminder of what we really need to do with a ticket created event 3 00:00:09,250 --> 00:00:11,850 inside of our order service. 4 00:00:11,870 --> 00:00:14,730 All right so you might recall looking at this diagram right here. 5 00:00:14,890 --> 00:00:18,140 So we've got the ticket created event coming to order service. 6 00:00:18,140 --> 00:00:22,160 The reason we are listening for this event inside of order service is so we can take the information 7 00:00:22,160 --> 00:00:26,750 about this ticket that was just created and save it in a local tickets collection. 8 00:00:26,750 --> 00:00:30,390 This is a classic example of data replication between different services. 9 00:00:30,410 --> 00:00:35,210 We are saving this information about this ticket so that when the order service needs to know some details 10 00:00:35,210 --> 00:00:40,340 about a ticket it does not have to do synchronous communication over to the ticket service to learn 11 00:00:40,340 --> 00:00:42,920 about the different tickets that are are available. 12 00:00:42,920 --> 00:00:47,600 So all we really need to do here is pull off some information about the ticket that was just created 13 00:00:47,720 --> 00:00:50,180 and save it to our local tickets collection. 14 00:00:50,180 --> 00:00:51,700 That's it. 15 00:00:51,850 --> 00:00:56,080 Back inside of our Ed we'll find the on message function. 16 00:00:56,130 --> 00:00:59,100 We're going to take a look at that data object right there. 17 00:00:59,160 --> 00:01:04,340 The only properties we really want to persist inside of our order service is title and price. 18 00:01:04,500 --> 00:01:09,780 And you might recall that by looking at our ticket model inside the order service again the only thing 19 00:01:09,780 --> 00:01:17,930 we really care about right now is tile and price so we're going to pull off title and price from data 20 00:01:19,190 --> 00:01:21,340 or then use that to build a new ticket 21 00:01:26,470 --> 00:01:27,540 and then save it. 22 00:01:27,550 --> 00:01:32,430 So we'll do it in a weight ticket not save because we are using the awake keyword. 23 00:01:32,440 --> 00:01:35,080 Let's make sure we mark the enclosing function as async 24 00:01:37,890 --> 00:01:42,300 and then assuming that all these steps go as expected and then we don't have any air we're then going 25 00:01:42,300 --> 00:01:44,100 to want to act that message. 26 00:01:44,100 --> 00:01:48,150 Remember when we act the message that tells Natsumi server that we have processed this thing and we 27 00:01:48,150 --> 00:01:49,230 are good to go. 28 00:01:49,250 --> 00:01:56,180 So at the very bottom we will do a message dot EQ like so well that is pretty much it for our first 29 00:01:56,240 --> 00:01:58,410 on message function pretty straightforward. 30 00:01:58,460 --> 00:01:59,800 Now unfortunately. 31 00:02:00,140 --> 00:02:02,180 Well you know how life is. 32 00:02:02,210 --> 00:02:06,260 Turns out that even though this looks really simple and it looks like everything will work as expected. 33 00:02:06,260 --> 00:02:08,680 We've got some big issues inside of here. 34 00:02:08,870 --> 00:02:10,330 So let's take a quick pause right now. 35 00:02:10,430 --> 00:02:14,090 When we come back the next video I want to mention the first big issue that we're going to run into 36 00:02:14,300 --> 00:02:17,240 if we continue with this implementation that we see currently.