Complete your route for the Order entity

With the map defined, use the information you copied to your clipboard in the previous section to easily complete the route.

1. Finalize the route

Step

Action

1

On the main menu, click Routes. The order route you created earlier should still be selected. See the procedure on how to create a route.

2

Put your cursor at the end of the <simple>${body}</simple> line and press the Enter key to create a blank line.

3

With your cursor on the blank line, paste the contents of your clipboard in the route. The formatting is not tidy but that can be fixed before you save the route.

The pasted text adds 4 XML sections that define the following parameters:

setBody – Everything inside these tags is considered as the body of your route.

map-create – These tags select the map parameter.

map-entry – Inside these tags, select the data from your route to transmit to the parameter.

to uri – Tells the route which mapping to use for this body of information.

Within the pasted values, some comment lines tell you where to add the expressions to select the data from your resource. For example, you will see a statement like: 

<!-- Add expression for Customer Name -->

4

Because the parameters in the mapping have the exact same name as the headers of the CSV file, you want Camel to automatically map the parameters. To do this, remove all the lines you just pasted except for the last one, containing the to uri parameter.

5

In the csv element add the modifier useMaps="true", like you did for skipHeaderRecord and delimiter earlier.

Note: Even though there is no attribute for Timestamp, your route needs to provide that information to the map in order to set the Resolution times correctly.

The last line in the pasted text directs the selected fields to your mapping for Order.

6

Clean up your XML syntax.

Click the last button above the text box where you have been writing your route. The tooltip says Format.


Tip

Decision Insight only formats XML that is correctly formed. When clicking Format, if nothing changes, it means there is an issue with your syntax and you need to fix it.

7

Your route is complete. The image below should match your route. Take a look and see if they compare.



8

Click Save.



Did you know: Reading the from and to tags

At the start of your route, you pasted the from tag. This is the directive that tells the route where/how to get the data. In this case, the source is identified by the URI that points to the name of your resource.

The syntax between the from and to break apart the data from your resource and direct it to specific parameters in your map. But there is one more type of "to" URI that can help you with debugging.

2. Add logs to your route

While you are in the process of developing or debugging routes, having more log information is better than having too little.

Go back and look at your route. There are three logical places to create logs within your route to show you how the route commands and your data are interacting. All three use the same to command:

<to uri="log:Orders:showBody=true"/>

Insert the log commands in the following places in your route:

  1. Directly after the from uri line at the beginning of your route. 

  2. Between the </unmarshal> and <split> commands.

  3. After the to command that directs the output to your Order map. 

You will get log results after you run the route.

Typically, the routes for static events differ from the routes for transaction or process events. Routes for static data are most often used to import configuration information into the application. They are not run continuously but could be run periodically to update the information available to the application – for example, they might run once at the start of each day to update the deployment on clients or configurations.

Routes for transactional data – once you are past the debugging stage – normally run continuously, waiting for new data.

Tip: Frequent backups

It is important to back up your solution frequently. Now is an ideal time to create a backup. For more information about how to create an application backup, see Create a Backup.


Related Links