QuickFIX/J User Manual

Repeating Groups

QuickFIX has the ability to send messages containing repeating groups and even recursive repeating groups. All repeating groups begin with a field that indicates how many repeating groups are in a set. A group can be created by referencing a class named after this field scoped within the parent message or group.

Creating Messages With Repeating Groups

Here is an example of a message that distributes market data. When the message is created the required field with the number of repeating groups is set to zero. This is because QuickFIX will automatically set this field for you when you add groups. This way there is never an inconsistancy between the number of entries in the field and in the message.

package quickfix;

quickfix.fix42.MarketDataSnapshotFullRefresh message =
  new quickfix.fix42.MarketDataSnapshotFullRefresh(new Symbol("QF"));

quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries group =
  new quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries();

group.set(new MDEntryType('0'));
group.set(new MDEntryPx(12.32));
group.set(new MDEntrySize(100));
group.set(new OrderID("ORDERID"));
message.addGroup(group);

group.set(new MDEntryType('1'));
group.set(new MDEntryPx(12.32));
group.set(new MDEntrySize(100));
group.set(new OrderID("ORDERID"));
message.addGroup(group);

Reading Messages With Repeating Groups

To pull a group out of a message you need to supply the group you wish to pull out. You should first inspect the number of entries field (which the group is named after) to get the total number of groups. The message that was created above is now parsed back out below.

package quickfix;

NoMDEntries noMDEntries = new NoMDEntries();
message.get(noMDEntries);
quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries group =
  new quickfix.fix42.MarketDataSnapshotFullRefresh.NoMDEntries();
MDEntryType MDEntryType = new MDEntryType();
MDEntryPx MDEntryPx = new MDEntryPx();
MDEntrySize MDEntrySize = new MDEntrySize();
OrderID orderID = new OrderID();

message.getGroup(1, group);
group.get(MDEntryType);
group.get(MDEntryPx);
group.get(MDEntrySize);
group.get(orderID);

message.getGroup(2, group);
group.get(MDEntryType);
group.get(MDEntryPx);
group.get(MDEntrySize);