Custom Relay Plugin¶
The relay is used for sending messages to and from AMI. Any external application interfacing with AMI does so via the relay. More detail on the content and format of relay messages can be found here.
You can modify messages being sent to and from AMI via the custom relay plugin. Additionally, this document contains instructions for the FIX relay plugin.
Overview¶
The AMI Relay Plugin allows for custom processing of the Realtime Messaging API.
When a message has been processed by the relay, depending on the logic the user has supplied, AMI will perform different actions. A list of the return message values to use and their corresponding behavior is below.
Return Value | AMI Behavior |
---|---|
ERROR | The errorSink message gets printed, and the incoming message is not processed |
NA | The mutableRawData value is ignored and the original message is processed by AMI |
SKIP | The incoming message is not processed |
OKAY | The mutableRawData value is processed by AMI |
You can use these flags to set the behavior and functionality of your custom relay messages.
Requirements¶
Like any other custom plugin, the relay plugin must implement the appropriate Java factory. To set up a custom relay, you will first need to follow the general instructions for setting up a custom plugin.
Java Interface¶
Properties¶
Unlike most other plugins, to use custom relay messaging, you do not specify the plugin via local.properties
.
Instead, upon establishing an initial connection to the real-time relay port (3289 by default), pass this login message to AMI:
replacing "demo"
with your AMI login details.
Example¶
This is a demonstrative sample of how you can use the relay plugin factory.
This simple plugin has the following behavior:
- Checks that the message has the prefix "SAMPLE". If it does not, the message is ignored (
NA
). - Checks that the message is not empty. If it is, it throws an error (
ERROR
). - If the message passes both checks, it creates a row in a table named "Table" with a value of 100 (
OKAY
,"O|T=\"Table\"|val=100"
).
Blank AmiRelayPlugin
Java File¶
FIX Message Parser¶
Overview¶
The AMI FIX parser utilizes the custom relay functionality explained above to receive messages in FIX format and add them to a table within AMI.
Properties¶
The FIX parser is available within AMI with the following configurable properties, which can be added to your local.properties
file:
-
Default:
FIX|
- Expected prefix for the messages coming in.
-
Default:
=
- Expected equals symbol.
-
Default:
|
- Expected delimiter symbol.
-
Default: None
- Keys to ignore.
-
Default:
35
- Used to specify the output table in AMI
-
Default: None
- Allows you to specify definitions for the tag within AMI.
Connect¶
To use the parser, you will need the port corresponding to the property ami.port
. By default this is 3289.
When logging in, send the following message:
ensuring to replace your login information with the correct input.
Example¶
Here is an example FIX formatted message that can be sent to AMI:
Setting the property ami.fixplugin.tag.99=string TEST
results in the following output in AMI:
the "99" tag has now been renamed within AMI to "TEST".
Note
There are additional helper methods for parsing FIX methods which may be useful when writing custom classes, but require the out.jar
file to be in your Java project build path. If you need any help with this, please contact us at support@3forge.com.