Management by Exception
The less you have to interact with a running flow, the stronger it is. The development of a ‘happy flow’ is often quite easy, but also just the beginning of a successful integration. We are only human after all and should acknowledge that our work is full of mistakes, wrong assumptions and shortcomings.
“All humans make mistakes. What determines a person's character aren't the mistakes we make.
It's how we take those mistakes and turn them into lessons rather than excuses.”
― Colleen Hoover, It Ends with Us
And even if you would develop flawless integrations you’ll see that sometimes endpoints react unexpectedly or not at all.
Therefore a good practice is to monitor your flows with ‘Management by Exception’, handle recurring exceptions within your integrations and follow an iterative development process to (re)act appropriately. This guide will show you how to “take those mistakes and turn them into lessons” in Dovetail flows.
1. Goal of this guide
The goal of this guide is to show you how to develop your integrations in a way that exceptions can be monitored in one dataset and/or handled right away. This gives you a birds eye view over multiple running integrations, focusing your attention on the areas where it matters most, the deviation of the mean / the expected.
1.1 Good practices
We have defined 4 good practices for Management by Exception within Dovetail:
- 3. Error Route Monitoring (ERM)
Monitor messages that end up in the Error Route and log them in a single location. - 4. Define the expected response
Define the response you expect, and therefore the exceptions, of an endpoint. - 5. Flow Function Monitoring (FFM)
Monitor flow function exceptions and log them in a single location. - 6. Error handling
Handle recurring erroneous responses directly in your flow.
1.2 Scope
In this guide we will focus on HTTP calls, but these good practices are translatable to other types of endpoints and/or components i.e. FTP. Each will have their own methods of communicating the status of your request.
Data validation, i.e. with XSL(T), is outside of the scope of this guide.
1.3 Prerequisites
- Dovetail 4.15.0 instance (minimum) with the Management by Exception example flow below installed
- SQL database:
- Make sure you have the following database info / credentials:
- host
- database name
- username
- password
- port
- See 8.3 Create SQL database for queries to create and test the database table
- Make sure you have the following database info / credentials:
- Basic knowledge of sending HTTP requests with Postman
1.4 Downloads
Right click, save link as.
2. Monitoring & Error Handling
After the development of your flow most messages between Dovetail components are already free from errors ‘by design’. You’ve developed, tested and debugged your flow’s functionality. During this process you have solved errors, poor interactions and other issues that surfaced. When you are ready to put your flow into production your integration is ‘permanently arranged’, meaning: there is a set route with a set amount of predefined steps.
The biggest challenge now is how to handle exceptions while your integration is up and running. These deviations occur where variables are introduced that are unaccounted for, for instance in communication.
Some examples:
- An FTP server is not available when you try to get a file from it
- You send a HTTP request to a server that responds with an error code or no response at all
- There are unexpected values or value types in a data source
- Data is running through the flow more frequently, resulting in ‘over asking’ an endpoint
- Datasets are growing in size over time, causing performance issues
2.1 Management by Exception
Often exceptions are not directly related to Dovetail’s performance as an Integration Platform. They reveal blind spots in your design & development process and show progressive insights into previously unknown areas of your integration. It shows the importance of monitoring which increases your awareness and understanding so you can improve and learn. Ultimately making your integrations stronger and less dependent. We call this ‘Management by Exception’ and it underlines the need for an iterative development process. Management by Exception gives you the opportunity to and benefits of monitoring multiple integrations in one dataset.
2.1.1 Technical vs. Functional exceptions
It’s hard to define the line between a technical and a functional exception. In general technical exceptions originate from the ‘performance’ of technologies used and have the potential to terminate an integration completely. Functional exceptions in general originate from business rules, data quality and/or the ‘function’ of a flow. You can imagine there’s a big grey area in between.
Technical Exceptions
A technical exception is an event that goes wrong because of a technical error. Technical exceptions can terminate the continuation of a flow. Often they are pretty easy to find, they end up in the Error Route as a failed exchange or in the Flow Manager logs. They can have a specific exception header, message or body pointing towards the origin of the error.
Monitoring the Error Route of your flow acts as a catchall for any exchanges between components that failed in your integration.
Functional Exceptions
Functional exceptions are more related to the content of your integration and to a lesser extent about the technology. Their origin can be as easy to spot as technical exceptions because they communicate similar error messages as a technical error. For instance a 401 error indicating your credentials are outdated or a ‘400 bad request’ error when you try to post data to an endpoint.
But they can also go under the radar and then they are more difficult to spot. For instance you sent a get request to an HTTP endpoint:
- It sends back an error response, but you have not defined the expected response
- Unwillingly your flow continues and uses the response to set a header with XPath
(it gets set to ‘null’ because the data you expect to be there actually is not) - Then you post a request to another endpoint that using this header value and your data doesn’t get posted
While analysing these kinds of exceptions the culprit seems to be the 2nd request at first sight, while actually the error originated much earlier. In this guide we show you how to define the expected response to prevent this, how to monitor the function of flows and how to handle recurring exceptions as they occur.
3. Error Route Monitoring (ERM)
The first step to start managing exceptions efficiently is to log exchanges that end up in the Error Route of your flows. You can think of the Error Route as a safety net that catches all failed exchanges. We have defined monitoring in the Error Route as Error Route Monitoring (ERM).
Every flow’s Error Route contains a FailedExchange component. Messages that end up at this component weren’t completed successfully in the Route. A message in the Error Route often contains valuable information about why it ended up there. In the Error Route you can build a flow that logs this data, for example in a SQL database.
Refer to our Using exceptions guide for a full reference on exceptions and the expressions to retrieve them from a failed exchange.
Using email
Be advised that the amount of data that flows through your integrations has the potential to create a lot of errors in a small amount of time. Therefore email should only be used when it concerns low frequency of data, in a test scenario or incidental errors. We recommend logging failed exchanges to a SQL database and create separate ‘reporting’ flows with the database as a source.
3.1 Why use Error Route Monitoring?
It’s good practice to monitor failed exchanges that go to the Error Route in a single data set. When the amount of active flows you manage increases it’s much more efficient to log them in one location. Our ERM component allows for multi-instance, multi-tenant and multi-environment logging in one database table. This one dataset acts as your starting point for reporting and analysis, instead of having to monitor individual flow logs & transactions.

3.2 ERM Component
Below you see a screenshot with the contents of our ERM component. It logs data from failed exchanges in the database, independent from the source of the exception. There can be HTTP, FTP, XPath, XSLT, type conversion errors and more.

See 8.1 SQL Monitoring Table Structure for a full list and the definition of metrics stored.
3.2.1 Install & Implement ERM component
- Import ERM.json into your tenant
- Update the Flow settings with your database info / credentials (see image below)
- Optional: Add ERM User Definable Metrics in the Flow settings of the component
(if you edit the variables here they are going to be imported in every flow you add this component to) - Test the SQL connection in the Route by clicking the blue ‘Test Connection’ button
- Install the Component
- Navigate to the Error Route of the flow you want to add it to, in this case the Management by Exception example
- Drag & drop the ERM component from the Component library onto the canvas
- Connect to the FailedExchange component
- Optional: Update ERM User Definable Metrics in the Flow settings
(see specify User Definable Metrics per flow) - Install the Flow

Every flow that has this ERM component in it's Error Route will now log these failed exchanges to the database. You can use it to monitor multiple flows across multiple instances and/or tenants in one location.
3.3 ERM: Simulate errors
In the Route of the Management by Exception example there’s an Inbound HTTPS followed by a JSONtoXML and an Http component.
- Verify the Inbound HTTPS component has a valid Endpoint setting
- Verify the Http component setting ‘Use error route’ is set to ‘Yes’
After you have connected successfully with your database you can install the flow, in test or production. Now it is time for the interesting part; to force some non-HTTP and HTTP errors to see the results of ERM.
3.3.1 ERM: Non-HTTP error
Use Postman to send a body with an valid JSON to the Inbound HTTPS url of this flow, i.e.
{
Observe the created database entry with all the metrics collected to indicate when the exception occurred and where it originated from. Notice the provided information about the content / type of the exception.
error_message
The provided JSON could not be parsed to either a JSON object or a JSON array.
error_class
class org.json.JSONException
3.3.2 ERM: Another Non-HTTP error
Use Postman to send an empty body to the Inbound HTTPS url of this flow.
Observe the created database entry with all the metrics collected to indicate when the exception occurred and where it originated from. Notice the provided information about the content / type of the exception.
error_message
No body available of type: ... No type converter available to convert from type: null to the required type: ...
error_class
class org.apache.camel.InvalidPayloadException
3.3.3 ERM: HTTP error
Use Postman to send a body with an valid JSON to the Inbound HTTPS url of this flow, i.e.
{}
And a header with key:
url
And value:
https://start.exactonline.nl/api/v1/1234567/salesorder/SalesOrders
Observe the created database entry with all the metrics collected to indicate when the exception occurred and where it originated from. Notice the provided information about the content / type of the exception, including the exception body that often contains very specific information about the error.
error_message
HTTP operation failed invoking ... with statusCode: 401
error_body
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="">Unauthorized - Authentication required</message>
</error>
error_class
class org.apache.camel.http.common.HttpOperationFailedException
4. Define the expected response
It’s tempting to let your flow continue with integration steps after an HTTP call, assuming the response will always be fine. We see flows as shown in the image below a lot, with an Http component with ‘Use error route’ option set to ‘Yes’. The Velocity component in the image represents the continuation of an integration.

4.1 Why define the expected response?
You happily assume nothing will go amiss after the Http component and continue with your integration. While actually, you have no clue if or how the endpoint is responding. This will eventually lead to all sorts of errors down the line and you will have to consult the Flow Manager logs and transactions to see what went wrong.
This is not a question of if, but when. That’s why you define the expected response.
As mentioned before, verifying the validity of the content of the response is outside of the scope of this guide. We will focus on defining successful communication with an endpoint.
4.2 Managing responses in Dovetail
Dovetail’s Content Router is the ideal tool to manage HTTP responses. It’s important to set the ‘Use error route’ option in the Http component to ‘No’ for this to work. Imagine the use case in the example we’ve provided expects a correct HTTP call to have a response code 200.
Add a Content Router with a rule called 200_success
defined with the following Simple Expression syntax: ${header.CamelHttpResponseCode} == '200'
All responses that adhere to this rule will continue along this route and all other responses will be routed out the otherwise
rule so they do not cause issues further down the line anymore. See the image below.

You will have to define the expected response in the Content Router with an applicable rule expression for your endpoint.
- An HTTP response header
200
or201
with a simple expression - A response body with an empty XML
<error></error>
element with XPath - A response body with a JSON key & value
{"Success" : true}
with JsonPath - Any other means your endpoint communicates status, refer to the documentation
The otherwise
rule in this example only logs to the Flow Manager. The last step for monitoring is to store the relevant metrics of an exception occurring in the Route of a flow into the database. This is the start of Flow Function Monitoring (FFM).
5. Flow Function Monitoring (FFM)
The next step is to store all the responses in the Route that are not expected in one location. Because the dataset is very similar to ERM we are using the same database table.
5.1 Why use Flow Function Monitoring?
Just like with ERM it’s good practice to monitor exceptions in your integration in a single data set. FFM also allows for multi-instance, multi-tenant and multi-environment logging in one database table. This one dataset acts as your starting point for reporting, analysis and error handling, instead of having to monitor individual flow logs & transactions.

5.2 FFM Component
The FFM flow follows the same steps as ERM in general. Again, it’s important to set the ‘Use error route’ option in the Http component to ‘No’. Above you can see otherwise
is now used to store data from exceptions in the Route. In this example everything except responses with a 200 HTTP code.
Below you see a screenshot with the contents of our FFM component.

See 8.1 SQL Monitoring Table Structure for a full list and the definition of metrics stored.
5.2.1 Install & Implement FFM component
- Import FFM.json into your tenant
- Update the Flow settings with your database info / credentials (see image below)
- Optional: Add FFM User Definable Metrics in the Flow settings of the component
(if you edit the variables here they are going to be imported in every flow you add this component to) - Test the SQL connection in the Route by clicking the blue ‘Test Connection’ button
- Install the Component
- Navigate to the Management by Exception example
- Drag & drop the FFM component from the Component library onto the canvas
- Connect to the Otherwise rule of the Content Router
- Optional: add a SetHeaders component after the Http component if it's important to log its response time, with:
- Header Name:
Set_ComponentResponseTime
- Simple expression:
${header.ComponentResponseTime}
- Header Name:
- Optional: Update FFM User Definable Metrics in the Flow settings
(see specify User Definable Metrics per flow) - Install the Flow

Every flow that uses this technique will now log functional exceptions to the database. You can use it to monitor multiple flows across multiple instances and/or tenants in one location. Specific errors that keep occuring can be subject for implementation of error handling, see 6. Error Handling.
5.3 FFM: Simulate errors
In the Route of the example there’s an Inbound HTTPS followed by a JSONtoXML and an Http component.
- Verify the Inbound HTTPS component has a valid Endpoint setting
- Verify the Http component setting ‘Use error route’ is set to