Trade messaging

Trade messages are passed between clients and Liberator as updates to subscriptions. The subject of the update identifies it as a trade message.

Trade messaging is configured into Liberator when you use the Caplin Integration Suite to create a Trading blade and then deploy the blade using the Caplin Deployment Framework. The Trading blade consists of a Trading Adapter and associated configuration, plus configuration for Liberator and Transformer. You don’t normally need to be concerned with how Liberator is configured to support trade messaging, since the Caplin Integration Suite does it all for you when you create the Trading blade.

But if you’re interested, here’s how it works under the hood…​

In the Liberator configuration a base subject name is defined for the subscriptions as a "built-in" Liberator object that’s created when Liberator starts up. For example, the base subject name could be /PRIVATE/TRADE, so that all trade messages sent between clients and Liberator have a subject name that starts with /PRIVATE/TRADE.

The Liberator configuration looks like this:

add-object
   name      /PRIVATE/TRADE
   ...
end-object

A client opens a Trade Channel by subscribing to one of the built-in Liberator trade message objects, for example, /PRIVATE/TRADE. Because Liberator and the Trading Adapter that it talks to need to manage many end-users who are simultaneously trading, the Liberator maps the generic trade message objects onto user specific object names. This mapping defines the unique channel over which each end-user trades. The mapping is defined through an object mapping in the Liberator, like this:

object-map /PRIVATE/TRADE/%1 /PRIVATE/%U/TRADE/%1

%U is the Liberator session username of the trading user.

%1 is a placeholder representing any variable length string appearing in the subject name of the subscription.

When the end-user 'john' connects to Liberator and trades, the trade messages sent between the client and Liberator have a subject name of the form:

/PRIVATE/TRADE/FX

Before passing an incoming trade message to the Trading Adapter, Liberator maps the subject name in the message according to the object-map configuration, so the subject of the passed on message becomes:

/PRIVATE/john-0/TRADE/FX

john-0 is the Liberator session username assigned to the Liberator login of 'john'.

This transformation allows the Trading Adapter to distinguish between trade messages from 'john' and trade messages relating to other end-users. The Trade Channel for 'john' is uniquely defined by the first part of the message subject: /PRIVATE/john-0/TRADE/FX

Similarly, when Liberator receives a trade message with the subject /PRIVATE/john-0/TRADE/FX from the Trading Adapter, it can readily determine the client connection over which it should forward the message to the client, and the forwarded message is given the subject /PRIVATE/TRADE/FX.


See also: