Generic Branch Device

Generic Branch Device

The Generic Branch device forwards messages to one or more queues in other channels. It is loosely based on the HL7 Transform device, but supports any message type.

The UI is a table, where each row represents a target channel and queue. In the header, you have buttons to Add and Remove branches, perform stepping, and Manage Tables. You can also specify what to do with the message if it is not matched by any conditions:

  • Move the message to the Error Queue (default)

  • Move the message to the Filter Queue

  • Pass the message to the next device in the channel.

Each branch target has an Enabled state, a Condition (which is a Function), a target queue, and an optional Description.

image-20250916-182544.png

There are a number of built-in functions for JSON, XML, and tables, and you can easily write your own using the Custom Code Control in the Code tab. Your function signature should be:

public bool MyConditionFunction(IMessageContext context, …optional parameters)

You can use the [FunctionCategory], [FunctionDescription], and [ParameterDescription] attributes to specify how your function will be displayed to the end user.

The following trivial sample shows a condition function which looks for a match at a specific location within a string message.

image-20250916-184220.png

This appears as follows when selecting a branch condition function.

image-20250916-185338.png
Selecting the function from the functions menu
image-20250916-191104.png
Adding parameters to the condition function and viewing the output

If a message is selected within an upstream queue, it will be displayed in the In Viewer. The predicted branch operations are displayed in the Out Viewer. This device does not alter the incoming message.

Branched messages retain the Correlation Key of the original message. This lets you search for all instances of a specific message within Connexion. It also powers the graphical message trace UI. See Correlation Key Searching for more information.

Tables

You can also use tables to determine branching (the existence of a specific value). Use the tables button to add a table, and then use a function which performs a table lookup.

image-20250916-191837.png

The above function is defined as:

[FunctionCategory(JsonCategory)] [FunctionDescription("Checks if the specified json path value exists in the 'In Value' column of the given map table.")] public virtual bool JsonPathInTable(IMessageContext context, string jsonPath, string mapTableName, string columnName) { if (string.IsNullOrWhiteSpace(jsonPath)) return false; if(context.Message is not string jsonString) return false; var obj = JToken.Parse(jsonString); var result = obj.SelectToken(jsonPath); if (result == null) return false; if (!MapTablesByName.TryGetValue(mapTableName, out var mapTable)) throw new Exception($"Map table with name '{mapTableName}' not found."); return mapTable.HasMatch(columnName, result.ToString()); }

Routing

The inverse of branching is ‘routing’. In this scenario, messages from multiple channels are sent to a single channel. A branch device with a single target queue is used to ‘route’ messages to the desired queue. This image shows an HL7 Branch device, but the concept is exactly the same.

image-20250916-174312.png