Most Enterprise Application Integration (EAI) scenarios mediate data between a source and a destination. Such scenarios often have a common set of requirements:
- Ensure that data from different systems are in correct format
- Perform “look-up” on incoming data to make decisions
- Convert data from one format to another (for example, from a CRM system's data format to an ERP system's data format)
- Route data to desired application or system
In this article, we look at a common integration pattern: "one-way message mediation" or VETR (Validate, Enrich, Transform, Route.) The VETR pattern mediates data between a source entity and a destination entity. Usually the source and destination are data sources.
Consider a website that accepts orders. Users post orders to the system using HTTP. Behind the scenes, the system validates the incoming data for correctness, normalizes it, and persists it in a Service Bus queue for further processing. The system takes orders off the queue, expecting it in a particular format. Thus: the end-to-end flow is:
HTTP -> Validate -> Transform -> Service Bus
The following BizTalk API Apps help in building this pattern:
HTTP Trigger - Source to trigger message event Validate - Validates correctness of incoming data Transform - Transforms data from incoming format to format required by downstream system Service Bus Connector - Destination entity where data is sent
In the Azure Management Portal, click on the +New button at the bottom-left of the screen and click Logic App. Choose a name, location, subscription, resource group, and location that works. Resource groups act as containers for your apps and all of the resources for your app go to the same resource group.
Next, let's add triggers and actions.
- Select HTTP Listener from the gallery to create a new listener. Call it HTTP1.
- Leave Send response automatically? setting as false. Configure the trigger action by setting HTTP Method to POST and setting Relative URL to /OneWayPipeline.
Now, let’s enter actions that run whenever the trigger fires -- that is, whenever a call is received on the HTTP endpoint.
- Add BizTalk XML Validator from the gallery and name it (Validate1) to create an instance.
- Configure an XSD schema to validate the incoming XML messages. Select the Validate action and select triggers(‘httplistener’).outputs.Content as the value for the inputXml parameter.
Now, the validate action is the first action after the HTTP listener. Similarly, let's add the rest of the actions.
Let's configure transforms to normalize the incoming data.
- Add Transform from the gallery.
- To configure a transform to transform the incoming XML messages, select the Transform action as the action to execute when this API is called and select
triggers(‘httplistener’).outputs.Content
as the value for inputXml. Map is an optional parameter since the incoming data is matched with all configured transforms, and only those that match the schema are applied. - Lastly, the Transform runs only if Validate succeeds. To configure this condition, select the gear icon on the top right to “Add a condition to be met”. Set the condition to
equals(actions('xmlvalidator').status,'Succeeded')
Next, let's add the destination -- a Service Bus Queue -- to write data to.
- Add a Service Bus Connector from the gallery. Set the Name to Servicebus1, set Connection String to the connection string to your service bus instance, set Entity Name to Queue, and skip Subscription name.
- Select the Send Message action and set the Message field for the action to actions('transformservice').outputs.OutputXml
Once pipeline processing is done, we send back an HTTP response for both success and failure with the following steps:
- Add an HTTP Listener from the gallery and select the Send HTTP Response action.
- Set Response Content to “Pipeline processing completed”, Response Status Code to “200” to indicate HTTP 200 OK, and condition to the expression
@equals(actions('servicebusconnector').status,'Succeeded')
Repeat the above steps to send an HTTP response on failure as well. Change the condition to @not(equals(actions('servicebusconnector').status,'Succeeded')).
Every time someone sends a message to the HTTP endpoint, it trigger the app and executes the actions we just created. To manage any such logic apps you create, click Browse in the Azure Management Portal and click Logic Apps. Click on your app to see more information.