Source Code
import biz.onixs.cme.dropcopy.handler.ErrorEventArgs;
import biz.onixs.cme.dropcopy.handler.Handler;
import biz.onixs.cme.dropcopy.handler.MessageEventArgs;
import biz.onixs.fix.parser.Group;
import biz.onixs.fix.parser.GroupInstance;
import biz.onixs.fix.parser.Message;
import biz.onixs.fix.tag.Tag;
import biz.onixs.util.settings.PropertyBasedSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Multisegment implements Handler.ErrorListener, Handler.WarningListener, Handler.HandlerListener {
private static final Logger LOG = LoggerFactory.getLogger(Multisegment.class);
private final ArrayList<Handler> handlers = new ArrayList<>();
private final ArrayList<ConnectionParameters> connectionParameters = new ArrayList<>();
private static class ConnectionParameters {
ConnectionParameters(String host, int port, String accessKeyID, String secretKey) {
this.host = host;
this.port = port;
this.accessKeyID = accessKeyID;
this.secretKey = secretKey;
}
String host;
int port;
String accessKeyID;
String secretKey;
}
public Multisegment() {
System.out.println("CME Drop Copy Handler Multisegment Sample.");
}
private void run(String... settingsFiles) throws Exception {
for (String settingsFile : settingsFiles) {
final PropertyBasedSettings settings = new PropertyBasedSettings(settingsFile);
final boolean isUpToDate = settings.getBoolean("UpToDate");
if (!isUpToDate) {
throw new Exception("Please update the configuration file (" + settingsFile + ") with up-to-date values");
}
Handler.setLicenseFile(settings.getString("LicenseFile"));
Handler.setLogDirectory(settings.getString("LogDirectory"));
Handler.setDialectFile("sample/CmeDropCopyFixDialect.xml");
String senderCompId = settings.getString("SenderCompID");
String targetCompId = settings.getString("TargetCompID");
String senderSubId = settings.getString("SenderSubID");
String targetSubId = settings.getString("TargetSubID");
String senderLocationId = settings.getString("SenderLocationID");
//Update defaults if necessary
LOG.info("Using defaults: ApplicationSystemVendor = {}, ApplicationSystemName = {}, ApplicationSystemVersion = {}",
Handler.ApplicationSystemVendor, Handler.ApplicationSystemName, Handler.ApplicationSystemVersion);
Handler handler = new Handler(senderCompId, targetCompId, senderSubId, targetSubId, senderLocationId);
handler.setErrorListener(this);
handler.setWarningListener(this);
handler.setHandlerListener(this);
handlers.add(handler);
final String host = settings.getString("Host");
final int port = settings.getInteger("Port");
final String accessKeyID = settings.getString("AccessKeyID");
final String secretKey = settings.getString("SecretKey");
connectionParameters.add(new ConnectionParameters(host, port, accessKeyID, secretKey));
}