"Event Broker" is a mechanism that enables communication and the flow of events between different parts of an application or between different microservices in an event-driven architecture.
It plays a crucial role in building scalable and flexible applications, allowing different parts of the application to respond to events and interact with each other asynchronously.
Prerequisites to this tutorial
- Git Installed https://git-scm.com/downloads
Attention!
In order to be able to follow this tutorial, it is recommended to do the tutorial regarding Business Events first.
https://medium.com/@mendixwithme/how-to-use-business-events-mendix-10-219ca7759514
Step by Step
1º Install Visual Studio Code and Docker.
VSCode: https://code.visualstudio.com/download
Docker: https://www.docker.com/products/docker-desktop/
2º Access "Event Broker Tools" page on Github and clone the repository by clicking on the "Code" button and copying the HTTPS link.
Github: https://github.com/mendix/event-broker-tools
Open a Git terminal inside the Mendix Folder and write "git clone https://github.com/mendix/event-broker-tools.git". Press Enter and wait.
3º Open the Visual Studio Code.
4º Select the Extension tab on the Side Menu and Search for "Docker". Select and install the Extension created by Microsoft.
5º After install, restart the VSCode and Open the folder with the cloned repository.
6º On the right side, go to the "local-setup" folder and right click on the "docker-compose.yml" file. Select the "Compose Up" option.
7º Go to BusinessEvents3 project (Check BusinessEvents tutorial if you don't have this project) and click on "Settings". Create a new configuration.
8º As a Name, write "BusinessEventLocalTest". Under the tab "Constants", add two new constants:
Name: BusinessEvents.ChannelName
Value: 'local'
Name: BusinessEvents.ServerUrl
Value: 'localhost:9092' (Windows) or
'YOUR-IPADDRESS:9094' (Linux/MACOS)
9º Click to "Activate" the new configuration. Run the project locally.
10º Do the same to the second app. Go to BusinessEvents4 project and click on "Settings". Create a new configuration.
11º Write "BusinessEventLocalTest" and under the tab "Server" change the "Runtime port" to "8081" and "Admin port" to "8091". We are changing this to be possible to execute both application at the same time.
12º Add two new constants:
Name: BusinessEvents.ChannelName
Value: 'local'
Name: BusinessEvents.ServerUrl
Value: 'localhost:9092' (Windows) or
'YOUR-IPADDRESS:9094' (Linux/MACOS)
It is important to check if your new configuration is active.
13º Run the project.
14º Inside the VSCode, confirm if all the topics have "Created" or "Started" after it.
15º Create a new Order object, selecting "Pending" as the order status.
Create a new Shipping object with the same status.
16º Go back to the first application and change the "order status" to "Cancelled". Return to the Shipping app and refresh the page. If everything went well, you should the "Shipping Status" as "Cancelled"
This is the end of the tutorial.
I'm creating a mendix community on discord to make life easier for devs. You can ask questions, help other people and have access to all the tutorials.
If you want to be part of this community, you can do so through this invite.
Discord: https://discord.gg/YHre8dXz3q
From the writer
If you enjoyed this article you can find more on our Medium page. For great videos, you can visit our Youtube page.
Are you interested in getting more involved with our community? Join us in our Discord Community Channel.
Top comments (0)