Contents
This sample demonstrates the use of the TIBCO StreamBase® Input and Output Adapters for FIX. See FIX Adapter for details on the structure and use of these adapters.
This sample uses four FIX adapters (two Input-Output pairs) to simulate two separate counterparties communicating using the
FIX protocol. The application uses one FIX Input adapter (FIXInput_1
) and one FIX Output adapter (FIXOutput_1
), linked to share their FIX connection, to act as the connection initiator. The second FIX adapter pair (FIXInput_2 and FIXOutput_2)
acts as the connection acceptor.
Note
In a typical StreamBase application, both FIX counterparties would not be running in the same process as they do in this sample. A more likely scenario would have one or more FIX adapters connected to FIX venues outside your company. However, for the purpose of this sample, keeping everything in one application improves clarity and ease of use.
In the sample application, the FIXOutput_1
adapter periodically sends a New Order Single
(MsgType="D") FIX message to the FIX target, FIXInput_2
. On receiving this message, the target routes it to the appropriate output port based on the settings in its Message Routing
Map. In this case, messages of MsgType g are routed to port 2.
Note
While this message is valid from a FIX protocol standpoint (that is, all required fields are set), it is not necessarily complete. This message is meant to demonstrate how to send messages and how to route them to specific ports on the receiving side.
When the New Order Single message is received, an Execution Report (MsgType="8") message is generated and sent back to FIXInput_1.
The sample application is configured to be run using the QuickFIX/J FIX engine, but you can easily use the StreamBaseFIX FIX engine to run it instead (provided you have the appropriate license to do so). To change the application to use this engine, follow these steps:
-
Open
fix.sbapp
in StreamBase Studio. -
Click on the FIX Output Adapter named
FIXOutput_1
in the EventFlow editor. -
In the StreamBase Properties view's Adapter Properties tab, in the FIX Engine drop-down control, select the StreamBaseFIX engine.
-
In the FIX Configuration File control, select
StreamBaseFIX-config-1.xml
. -
Make the same changes for the FIX Output Adapter named
FIXOutput_2
, this time selectingStreamBaseFIX-config-2.xml
as the FIX Configuration File. -
Save the
fix.sbapp
file before running.
In StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, select
> . -
Enter
fix
to narrow the list of options. -
Select FIX adapter from the StreamBase Trade Execution Adapters category.
-
Click
.
StreamBase Studio creates a project for this sample.
-
In the Project Explorer view, open the sample you just loaded.
If you see red marks on a project folder, wait a moment for the project to load its features.
If the red marks do not resolve themselves after a minute, select the project, right-click, and select
> from the context menu. -
Open the
src/main/eventflow/
folder.packageName
-
Open the
fix.sbapp
file and click the Run button. This opens the SB Test/Debug perspective and starts the module. -
In the SB Test/Debug Perspective, open the Output Streams view.
-
Look for tuples emitted on the
AdminMsgFromFIXAdapter_1
andAdminMsgFromFIXAdapter_2
streams to indicate that Logon messages (MsgType=A) are exchanged. -
Also look for tuples being emitted every five seconds on the NOSMsgFromFixOutput_1 stream, indicating that FIX messages of type D are sent from FIXOutput_1 to FIXInput_2. The messages are routed to that port instead of the first port because the FIXInput_2 adapter is configured to route all application level messages of type D to the second port (and all others to port 1.)
-
Once a New Order Single message has been generated, look for an Execution Report (MsgType='8') response to be sent back from FIXOutput_2. You will see this message being received by the
ExecutionReportMsgFromFIXAdapter_2
stream. -
In the Manual Input view, select the Commands stream. Enter the following values and click
:-
Command:
ResetSession
-
BeginString:
FIX.4.2
-
SenderCompID:
FIXAdapter_1
-
TargetCompID:
FIXAdapter_2
-
-
Observe the Logout and Logon messages in each adapter's admin-level message stream, signifying that the connection is being reset.
-
When done, press F9 or click the Terminate EventFlow Fragment button.
When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Important
Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:
studio-workspace
/sample_adapter_embedded_fix
See Default Installation Directories for the default location of studio-workspace
on your system.