...
Maven users will need to add the following dependency to their pom.xml for this component:
Code Block |
|
|
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quickfix</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
|
URI format
Code Block |
quickfix:configFile[?sessionID=sessionID]
|
The configFile is the name of the QuickFIX/J configuration to use for the FIX engine (located as a resource found in your classpath). The optional sessionID identifies a specific FIX session. The format of the sessionID is:
Code Block |
(BeginString):(SenderCompID)[/(SenderSubID)[/(SenderLocationID)]]->(TargetCompID)[/(TargetSubID)[/(TargetLocationID)]]
|
Example URIs:
Code Block |
quickfix:config.cfg
quickfix:config.cfg?sessionID=FIX.4.2:MyTradingCompany->SomeExchange
|
...
Minimal Initiator Configuration Example
Code Block |
[SESSION]
ConnectionType=initiator
BeginString=FIX.4.4
SenderCompID=YOUR_SENDER
TargetCompID=YOUR_TARGET
|
...
Add "exchangePattern=InOut" to the QuickFIX/J enpoint URI. The MessageOrderStatusService in
the example below is a bean with a synchronous service method. The method returns the response
to the request (an ExecutionReport in this case) which is then sent back to the requestor session.
Code Block |
from("quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:MARKET->TRADER&exchangePattern=InOut")
.filter(header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.ORDER_STATUS_REQUEST))
.bean(new MarketOrderStatusService());
|
...
The correlation criteria is defined with a MessagePredicate object. The following example will treat
a FIX ExecutionReport from the specified session where the transaction type is STATUS and the Order ID
matches our request. The session ID should be for the requestor, the sender and target CompID fields
will be reversed when looking for the reply.
Code Block |
exchange.setProperty(QuickfixjProducer.CORRELATION_CRITERIA_KEY,
new MessagePredicate(new SessionID(sessionID), MsgType.EXECUTION_REPORT)
.withField(ExecTransType.FIELD, Integer.toString(ExecTransType.STATUS))
.withField(OrderID.FIELD, request.getString(OrderID.FIELD)));
|
...
The following route receives messages for the trade executor session and passes application messages to the trade executor component.
Code Block |
from("quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:MARKET->TRADER").
filter(header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageReceived)).
to("trade-executor:market");
|
The trade executor component generates messages that are routed back to the trade session. The session ID must be set in the FIX message itself since no session ID is specified in the endpoint URI.
Code Block |
from("trade-executor:market").to("quickfix:examples/inprocess.cfg");
|
The trader session consumes execution report messages from the market and processes them.
Code Block |
from("quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:TRADER->MARKET").
filter(header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.EXECUTION_REPORT)).
bean(new MyTradeExecutionProcessor());
|
...
Note: The component can be used to send/receives messages to a FIX server.
URI format
Code Block |
quickfix-server:config file
quickfix-client:config file
|
...
When a message must be send to QuickFix, then you must create a QuickFix.Message instance.
Lazy creating engines
From Camel 2.12.3 onwards, you can configure the QuickFixComponent to lazy create and start the engines, which then only start these on-demand. For example you can use this when you have multiple Camel applications in a cluster with master/slaves. And want the slaves to be standby.
Samples
Direction : to FIX gateway
Code Block |
|
|
<route>
<from uri="activemq:queue:fix"/>
<bean ref="fixService" method="createFixMessage"/> // bean method in charge to transform message into a QuickFix.Message
<to uri="quickfix-client:META-INF/quickfix/client.cfg"/> // Quickfix engine who will send the FIX messages to the gateway
</route>
|
Direction : from FIX gateway
Code Block |
|
|
<route>
<from uri="quickfix-server:META-INF/quickfix/server.cfg"/> // QuickFix engine who will receive the message from FIX gateway
<bean ref="fixService" method="parseFixMessage"/> // bean method parsing the QuickFix.Message
<to uri="uri="activemq:queue:fix"/>"
</route>
|
Include Page |
|
|