Custom Business Event Component in Mule
You can use Custom Business Event (tracking:custom-event) components to add metadata and Key Performance Indicators (KPIs) to your flow.The key/value pairs can vary according to your business needs.
flow of Custom Business Event :
Custom Business Event configuration :
URL : http://localhost:8085/api/custom Method : POST
Input :
Output :
XML project code :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8085" basePath="/api" doc:name="HTTP Listener Configuration"/>
<flow name="test_custombuseventFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/custom" doc:name="HTTP"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<set-variable variableName="namevar" value="#[payload.name]" doc:name="Variable"/>
<tracking:custom-event event-name="Event" doc:name="Custom Business Event">
<tracking:meta-data key="id" value="#[payload.id]"/>
<tracking:meta-data key="name" value="#[flowVars.namevar]"/>
</tracking:custom-event>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
No comments:
Post a Comment