Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
We've now got an initial implementation of our event plus but together we're not going to start to go
through our Postal Service and our common service.
Anytime something interesting happens inside those services such as creating a new post or creating
a new comment we're gonna make sure that we send a request over to this events and point in our event
bus and in that request we're going to include the event event plus we'll then take that event and echo
it out to all the different services running inside of our application at present are different services
do not have this post events and point wired up.
So when the event bus tries to send that request over the request is going to fail due to a for a for
as soon as we make sure that the event bus can emit this event will then go back over and start to implement
these end points that the other services can listen to these events that are being emitted.
But again right now we're just gonna make sure that the Postal Service is going to meet this event anytime
someone creates a new post so let's get to it.
Between the last video and this one I opened up my code editor inside of my roots blog project directory.
We're going to start to have to change between all for these different services very quickly and so
it's just a lot easier to maneuver between them if we have all of our projects open inside of one editor
as opposed to four separate editors.
I'm going to find the post directory inside there I'll find the next dot J File at the very top.
I'll immediately require an axis like so and then going to scroll down to our post end point.
So this is the code that gets executed every single time someone tries to create new post.
So this would be a perfect time to try to emit an event saying hey someone just made a new post right
after we add the new post to our post collection.
I'll use axioms to make a post request over to age TTP.
Colin flash flash local host in four thousand five.
Because remember that is where a broker is running flash events
and then as the second argument we'll put in the actual event that we want to send over.
So for right now we'll say that every event that we met is going to have two properties.
The first one is going to be a type and that type describes that event that just occurred the second
property will be a data property and that will have some information that further clarifies exactly
what happened in the case of creating a post we'll probably include the actual post that was just created
as the data property.
Remember that event that we send out throughout our application can have any structure we want.
It doesn't have to be an object it can be a string or a number.
Any data you want to have.
But usually we're going to make sure that all these events have a very consistent structure.
We'll talk more about the design and sort of schema of events quite a bit over time.
Right now we're just gonna say that every event will have a type.
And data gets us the object right here is essentially the event that I want to have emitted or my entire
application going to give it a type of post created and then a data and data is going to be the post
that we just made.
I remember all of our posts have an I.D. and title.
That's essentially what our post is.
So we pretty much want to take that style of object right there included as the data property.
We'll say I.D. and title then finally this is an asynchronous operation making the network request.
So we will add on async and await like so that I'm going to say this we're gonna flip back over to our
browser and find our running react application.
I'm going to refresh this page and as soon as I do you'll notice that all the posts go away.
That is totally fine it's because remember all of our posts are being stored in memory with that post
service.
So as soon as we restart that server all of our posts just disappear.
All right I'll go ahead and try to create a post we'll call this new post and submit it.
We don't have any kind of live reload on the react application so I have to refresh the page as soon
as I do so I do see the new post appear.
What happened to that event.
Well let's go take a look at our terminal.
We'll take a look at our server logs.
We'll just make sure that the postal service did try to send that event over to the event plus that.
So here are my terminal logs right here.
This second window that I have right here.
That's kind of highlighted is the postal service.
I don't see any information there that's very interesting.
If I go down to the bottom window right here that is where might event broker or event plus is living
or actually running at present.
It looks like there was a couple of errors here so all these errors are identical in nature.
They'll say request failed with status for 0 4.
So that is actually good.
Remember as I mentioned just a moment ago our post service comment service and query service that doesn't
exist did it exist yet does not have this post slash events end point.
You don't have any way of actually receiving these events.
So even though the event bus is trying to send that event off.
Well there's nothing receive it which is why we're getting that forum for error.
So overall I'd say this looks good.
We are definitely emitting an event to the event bus anytime something interesting happens inside the
post service.
Let's take a pause right here and continue in just a moment.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.