Configure trade-model cache fields

In this tutorial we will look at configuring and using cache fields with a simplified trade model. In Trading Integration Adapter blades, the trademodels.xml file located in Blade/DataSource/etc specifies the various states and transitions that govern the lifecycle of a trade.


On receiving a client side TradeEvent, a trade is promoted to another state and the TradeEvent is then forwarded to a registered TradeListener (the generated <tradeModel name>TradeListenerAdapter), here the type is parsed and the event is sent out to the appropriate method on the < tradeModel name >TradeListener. In the implementation of this < tradeModel name >TradeListener, the trade can be obtained from the event and its cached fields' values can be extracted from the TradeEvent to be put onto the desired new <trigger>TradeEvent to be sent in response.


So here’s an example using the following simplified trade model:

cis simplified trade model
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
     <tradeModel initialState="Initial" name="ESP">
               <cacheField name="RequestID" where="server"/>
               <cacheField name="TradeDetails" where="server"/>
          <state name="Initial">
               <transition source="client" target="Processing" trigger="Open">
                    <field description="Request ID" name="RequestID" required="true"/>
                    <field description="Request Time" name="RequestTime" required="true"/
                    <field description="Trade Details" name="TradeDetails" required="true"/>
          <state name="Processing">
               <transition source="server" target="Confirmed" trigger="Confirmation">
                    <field description="Request ID" name="RequestID" required="true"/>
                    <field description="Confirmation ID" name="ConfirmationID" required="true"/>
                    <field description="Confirmation Time" name="ConfirmationTime" required="true"/>
          <state name="Confirmed"/>
               <stateAttr name="Initial" visible="true" x="275" y="42"/>
               <stateAttr name="Processing" visible="true" x="275" y="162"/>
               <stateAttr name="Confirmed" visible="true" x="275" y="300"/>
public class SimpleBackend implements ESPTradeListener

    public void onOpen(OpenTradeEvent event )
        ProcessingResponder responder = trade.getProcessingResponder();
        ConfirmationTradeEvent confirmationEvent = new ConfirmationTradeEvent(trade);

        // Copy all cached fields to outgoing message
        for (Map.Entry<String, String> field :trade.getFields().entrySet())
            confirmationEvent.addField(field.getKey(), field.getValue());

        // Set transition specific fields

        // Send the confirmation
        catch (TradeException e)


The OpenTradeEvent with which the onOpen method is called, in the ESPTradeListener implementation (above), will contain a trade with only the RequestId and TradeDetails cached. Therefore only those two fields will be transferred to the ConfirmationEvent by the for loop and TradeTime will not be accessible.

CacheField Options

When no cacheFields tag is present, all fields will be cached as before. If no cacheField tags are present within cacheFields, no fields will be cached. Each cacheField tag must have the attributes name and where:

<cacheField name="TradeDetails" where="server"/>

The attribute where can have one of three values:

  • server

  • client

  • both