Deploy Your First Event Handler¶
An event handler executes predefined actions in response to specific events. Devant simplifies the process of creating and deploying such integrations.
This guide walks you through the steps to create and deploy an Event Handler using WSO2 MI and Devant.
In this guide, you will build a simple event handler that monitors RabbitMQ for new messages and displays them once they become available.
Prerequisites¶
-
If signing in to Devant for the first time, create an organization:
- Go to https://console.devant.dev/ and sign in using your preferred sign-in option.
- Enter a unique organization name. For example,
Stark Industries
. - Read and accept the privacy policy and terms of use and click Create.
- Select your region and click Confirm.
-
Set up RabbitMQ:
- Use an existing RabbitMQ instance or start a new RabbitMQ instance on a server that can be accessed via the internet.
- Obtain the
username
,hostname
,password
, andvhost
from the RabbitMQ instance to use later as environment variables.
Step 1: Attach a Git repository¶
- Go to https://console.devant.dev/new and sign in. This opens the new integration page.
- On the new integration page, click Attach a Git Repository.
- Click Use a Third-Party Public Git Repository under Authorize with GitHub.
- Click Try with a sample. This will automatically pick a sample repository managed by wso2.
- Choose
/micro-integrator/RabbitMQIntegration
in the Path field. - Other fields are automatically populated for you. Choose the Integration Type as
Event Integration
. - Click Create.
Step 2: Configure the event handler¶
Once you create the event handler, Devant will automatically build and deploy it to the development environment. You can now configure the event handler.
- On the Development environment card, click Configure.
-
In the Configure pane, click + Add corresponding to Environment Configurations and add the following environment variables:
Tip
Use the values from your RabbitMQ instance as per the Prerequisites section for the environment variables.
Name Value HOSTNAME Hostname of your RabbitMQ server VHOST Virtual hostname of your RabbitMQ server USERNAME Username for connecting to RabbitMQ PASSWORD Password associated with the RabbitMQ username -
Click Update. This updates the event handler in the development environment.
Step 3: Test the integration¶
-
Send a sales order message to the SalesOrderQueue on the RabbitMQ server. You can send a sample sales order message similar to the following:
-
Observe the logs:
- You can view the order message in the logs pane of the development card.
Now you have gained hands-on experience in creating, configuring, deploying, and testing an event handler.