Developing Custom Routes

Overview

In some cases you would want to write a custom route to do some specific manipulation with message data that might be easier that processing through Crossfire.

These are extensions to Crossfire and is written typically using C# code, and building a separate DLL.

First you can create a project with Visual Studio, and make sure you are at least using .NET 4.0 for the project. Our current convention is to use .net Standard 2.0 for development.

There are a few pre-requsite installations required before you can begin development

Project setup

Open Visual Studio and click "Create a new project".

Search for the project type "C# class library". Select the option shown to the left

Configure your new project

After clicking next, you will be asked what Framework to use. We recommend .NET Standard 2.0

Click Create

Pre development

You should now have an empty project with a single Class1.cs file. Rename your file to Route.cs, and rename your class to Route

Right click on the Dependencies item in the solution explorer, and select "Add Project Reference". Use the "Browse" button at the bottom, and find the Sandfield.Messaging.dll file provided above. Click Add once you have selected the file, then click OK to close the menu.

In the code window, you can now make your class implemnet the IRouteMessage interface required for custom routes. Add " : IRouteMessage" after your "public class Route" declaration

You will then need to implement two methods. Paste these lines into your file and complete the method body

Development

Write the code for your custom route. Make sure to right click on your solution in the "Solution Explorer", and select "Build Solution" often. This will make sure there are no errors.

You can create new files, classes, methods, add nuget package references, and more. The final value of message.Attachments will be sent to your destination transport when your route has finished running.

Deployment

Create a new folder in your Crossfire engine directory to store the route. It is best to name the folder the same as your route eg "Sandfield.Messaging.CustomRoutes.ConvertXmlToJson"

Copy the route files from the bin folder into the new engine directory. The bin folder will be located in a subfolder of your project eg \\Sandfield.Messaging.CustomRoutes.ConvertXmlToJson\Sandfield.Messaging.CustomRoutes.ConvertXmlToJson\bin\Debug\netstandard2.0

Set up the route in crossfire. If you wish to use the CustomMatch method, check that option on the route.