diff --git a/administrator/version.properties b/administrator/version.properties index 637c6b0..6a9cbf9 100644 --- a/administrator/version.properties +++ b/administrator/version.properties @@ -1,2 +1,2 @@ -#Tue Sep 19 20:48:23 AEST 2023 -VERSION_BUILD=754 +#Wed Sep 20 19:01:37 AEST 2023 +VERSION_BUILD=781 diff --git a/exchange/build.gradle b/exchange/build.gradle index 0606664..49944aa 100644 --- a/exchange/build.gradle +++ b/exchange/build.gradle @@ -1,3 +1,4 @@ + plugins { // Apply the java-library plugin for API and implementation separation. id 'application' @@ -72,7 +73,7 @@ jar{ autoIncrementBuildNumber() manifest { attributes("Implementation-Title": "Gradle", - 'Main-Class':'com.alignmentsystems.matching.App', + 'Main-Class':'com.alignmentsystems.matching.AlignmentApp', 'class-path':'.' , 'Version': classifier + '.' + versionBuild) } @@ -98,5 +99,5 @@ java { application { // Define the main class for the application. - mainClass = 'com.alignmentsystems.matching.App' + mainClass = 'com.alignmentsystems.matching.AlignmentApp' } \ No newline at end of file diff --git a/exchange/src/main/java/com/alignmentsystems/matching/App.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentApp.java similarity index 89% rename from exchange/src/main/java/com/alignmentsystems/matching/App.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentApp.java index 4c5a28c..96603eb 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/App.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentApp.java @@ -6,7 +6,7 @@ * Date : 24th August 2023 * Copyright : Alignment Systems Ltd 2023 * Project : Alignment Matching Toy - * Artefact : App + * Artefact : AlignmentApp * Description : *****************************************************************************/ import com.alignmentsystems.library.AlignmentFunctions; @@ -17,14 +17,14 @@ * @author John Greenan * */ -public class App { +public class AlignmentApp { private final static String LOGBACKLOGNAME = "log.name"; public static void main(String[] args) { InstanceType instanceType = AlignmentFunctions.getInstanceType(args); System.setProperty(LOGBACKLOGNAME, instanceType.type); - InstanceWrapper wrapper = new InstanceWrapper(); + AlignmentInstanceWrapper wrapper = new AlignmentInstanceWrapper(); if (wrapper.initialise(instanceType)) { System.exit(FailureConditionConstants.INSTANCE_WRAPPER_INITIALISATION_ERROR); }; diff --git a/exchange/src/main/java/com/alignmentsystems/matching/FIXEngineExchange.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineExchange.java similarity index 72% rename from exchange/src/main/java/com/alignmentsystems/matching/FIXEngineExchange.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineExchange.java index 0f4693e..d71135d 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/FIXEngineExchange.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineExchange.java @@ -1,6 +1,8 @@ package com.alignmentsystems.matching; +import java.io.FileNotFoundException; import java.nio.ByteBuffer; +import java.util.Properties; /****************************************************************************** * @@ -16,20 +18,25 @@ import java.util.UUID; import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerRecord; import com.alignmentsystems.fix44.ExecutionReport; -import com.alignmentsystems.library.AlignmentExecutionReport; -import com.alignmentsystems.library.AlignmentOrder; import com.alignmentsystems.library.AlignmentDataMapper; +import com.alignmentsystems.library.AlignmentExecutionReport; import com.alignmentsystems.library.AlignmentFunctions; +import com.alignmentsystems.library.AlignmentKafkaSender; import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentOrder; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; import com.alignmentsystems.library.constants.Constants; import com.alignmentsystems.library.enumerations.Encodings; import com.alignmentsystems.library.enumerations.InstanceType; import com.alignmentsystems.library.enumerations.MessageDirection; import com.alignmentsystems.library.enumerations.OrderBookSide; -import com.alignmentsystems.library.interfaces.InterfaceQueueNonSequenced; +import com.alignmentsystems.library.interfaces.InterfaceFIXEngine; import com.alignmentsystems.library.interfaces.InterfaceKafkaMessageHandler; +import com.alignmentsystems.library.interfaces.InterfaceOrderSender; import quickfix.DoNotSend; import quickfix.FieldNotFound; @@ -46,21 +53,47 @@ * @author John Greenan * */ -public class FIXEngineExchange extends MessageCracker implements quickfix.Application , InterfaceKafkaMessageHandler{ - protected final static String CLASSNAME = FIXEngineExchange.class.getSimpleName(); - private InterfaceQueueNonSequenced queueNonSequenced = null; +public class AlignmentFIXEngineExchange extends MessageCracker implements InterfaceOrderSender, InterfaceKafkaMessageHandler, InterfaceFIXEngine, quickfix.Application { + protected final static String CLASSNAME = AlignmentFIXEngineExchange.class.getSimpleName(); private final static Encodings encoding = Encodings.FIXSBELITTLEENDIAN; private AlignmentLogEncapsulation log = null; private InstanceType instanceType = null; + private AlignmentPersistenceToFileClient debugger = null; + private KafkaProducer kafkaProducerB = null; - - public FIXEngineExchange(AlignmentLogEncapsulation log, InterfaceQueueNonSequenced queueNonSequenced, - InstanceType instanceType) { + @Override + public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger, InstanceType instanceType) throws FileNotFoundException ,NullPointerException{ + final String METHOD = "initialise"; + this.log = log; - + this.debugger = debugger; this.instanceType = instanceType; - this.queueNonSequenced = queueNonSequenced; + + debugger.debug(CLASSNAME + "." + METHOD); + + AlignmentUEH ueh = new AlignmentUEH(this.debugger); + Thread.setDefaultUncaughtExceptionHandler(ueh); + + + + + + + if (this.kafkaProducerB == null) { + Properties props; + try { + props = AlignmentFunctions.getProperties(AlignmentFIXEngineKafkaProducer.class.getClassLoader(), InstanceType.KAFKA.getProperties()); + } catch (FileNotFoundException | NullPointerException e) { + this.log.error(e.getMessage() , e); + throw e; + } + this.kafkaProducerB = new KafkaProducer<>(props); + } + + + + return true; } /** @@ -76,11 +109,12 @@ public FIXEngineExchange(AlignmentLogEncapsulation log, InterfaceQueueNonSequenc @Override public void onCreate(SessionID sessionId) { // TODO Auto-generated method stub - final String METHODNAME = "onCreate".intern(); + final String METHOD = "onCreate".intern(); StringBuilder sb = new StringBuilder().append(sessionId.toString()); - log.infoFIXSession(sb.toString(), sessionId, METHODNAME, CLASSNAME, instanceType); + debugger.debug(CLASSNAME + "." + METHOD); + log.infoFIXSession(sb.toString(), sessionId, METHOD, CLASSNAME, instanceType); } /** @@ -91,11 +125,12 @@ public void onCreate(SessionID sessionId) { */ @Override public void onLogon(SessionID sessionId) { - final String METHODNAME = "onLogon".intern(); + final String METHOD = "onLogon".intern(); StringBuilder sb = new StringBuilder().append(sessionId.toString()); + debugger.debug(CLASSNAME + "." + METHOD); - log.infoFIXSession(sb.toString(), sessionId, METHODNAME, CLASSNAME, instanceType); + log.infoFIXSession(sb.toString(), sessionId, METHOD, CLASSNAME, instanceType); } /** @@ -105,11 +140,12 @@ public void onLogon(SessionID sessionId) { */ @Override public void onLogout(SessionID sessionId) { - final String METHODNAME = "onLogout".intern(); + final String METHOD = "onLogout".intern(); StringBuilder sb = new StringBuilder().append(sessionId.toString()); + debugger.debug(CLASSNAME + "." + METHOD); - log.infoFIXSession(sb.toString(), sessionId, METHODNAME, CLASSNAME, instanceType); + log.infoFIXSession(sb.toString(), sessionId, METHOD, CLASSNAME, instanceType); } /** @@ -121,7 +157,9 @@ public void onLogout(SessionID sessionId) { */ @Override public void toAdmin(Message message, SessionID sessionId) { - final String METHODNAME = "toAdmin".intern(); + final String METHOD = "toAdmin".intern(); + + debugger.debug(CLASSNAME + "." + METHOD); Boolean errorEvent = Boolean.FALSE; StringBuilder sb = new StringBuilder(); @@ -131,7 +169,7 @@ public void toAdmin(Message message, SessionID sessionId) { try { thisMessageType = message.getHeader().getField(new quickfix.field.MsgType()).getValue(); } catch (FieldNotFound e) { - sb = new StringBuilder().append(METHODNAME).append(Constants.TAB).append(sessionId.toString()) + sb = new StringBuilder().append(METHOD).append(Constants.TAB).append(sessionId.toString()) .append(Constants.EQUALS).append(e.getMessage()); log.error(sb.toString(), e); errorEvent = Boolean.TRUE; @@ -141,7 +179,7 @@ public void toAdmin(Message message, SessionID sessionId) { sb = new StringBuilder().append(sessionId.toString()).append(" MessageType=[").append(thisMessageType) .append("] ").append(MessageDirection.SENT.value).append(" (") .append(message.getClass().getSimpleName()).append(")"); - log.infoFIXSession(sb.toString(), sessionId, METHODNAME, CLASSNAME, instanceType); + log.infoFIXSession(sb.toString(), sessionId, METHOD, CLASSNAME, instanceType); } } @@ -155,9 +193,10 @@ public void toAdmin(Message message, SessionID sessionId) { @Override public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon { - final String METHODNAME = "fromAdmin".intern(); + final String METHOD = "fromAdmin".intern(); String thisMessageType = null; + debugger.debug(CLASSNAME + "." + METHOD); try { thisMessageType = message.getHeader().getField(new quickfix.field.MsgType()).getValue(); @@ -166,7 +205,7 @@ public void fromAdmin(Message message, SessionID sessionId) throw e; } - log.infoFIXSession(message.toRawString(), sessionId, METHODNAME, CLASSNAME, instanceType); + log.infoFIXSession(message.toRawString(), sessionId, METHOD, CLASSNAME, instanceType); } @@ -184,7 +223,9 @@ public void fromAdmin(Message message, SessionID sessionId) */ @Override public void toApp(Message message, SessionID sessionId) throws DoNotSend { - final String METHODNAME = "toApp".intern(); + final String METHOD = "toApp".intern(); + debugger.debug(CLASSNAME + "." + METHOD); + } @@ -206,10 +247,12 @@ public void toApp(Message message, SessionID sessionId) throws DoNotSend { public void fromApp(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType { // TODO Auto-generated method stub - final String METHODNAME = "fromApp".intern(); + final String METHOD = "fromApp".intern(); String thisMessageType = null; StringBuilder sb = new StringBuilder(); + debugger.debug(CLASSNAME + "." + METHOD); + try { thisMessageType = message.getHeader().getField(new quickfix.field.MsgType()).getValue(); } catch (FieldNotFound e) { @@ -217,7 +260,7 @@ public void fromApp(Message message, SessionID sessionId) throw e; } - log.infoFIXSession(message.toRawString(), sessionId, MessageDirection.RECEIVED, METHODNAME, FIXEngineExchange.CLASSNAME, + log.infoFIXSession(message.toRawString(), sessionId, MessageDirection.RECEIVED, METHOD, AlignmentFIXEngineExchange.CLASSNAME, instanceType); try { @@ -232,6 +275,29 @@ public void fromApp(Message message, SessionID sessionId) } + /** + * + * @see QuickFIX + * @param message fix44.ExecutionReport that is to be processed... + * @param sessionID The FIX session on which the message was received + * @throws FieldNotFound Should not happen... + * @throws UnsupportedMessageType Should not happen... + * @throws IncorrectTagValue Should not happen... + */ + public void onMessage(com.alignmentsystems.fix44.ExecutionReport message, SessionID sessionID) + throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { + final String METHOD = "onMessage".intern(); + + StringBuilder sb = new StringBuilder().append(" Execution Report=(").append(" ExecID=(") + .append(message.getExecID()).append(") SessionID=(").append(sessionID.toString()).append(")"); + log.infoFIXSession(sb.toString(), sessionID, MessageDirection.RECEIVED, METHOD, + message.getClass().getSimpleName(), this.instanceType); + + } + + + /** * * @see QuickFIX - * @param message fix44.ExecutionReport that is to be processed... - * @param sessionID The FIX session on which the message was received - * @throws FieldNotFound Should not happen... - * @throws UnsupportedMessageType Should not happen... - * @throws IncorrectTagValue Should not happen... - */ - public void onMessage(com.alignmentsystems.fix44.ExecutionReport message, SessionID sessionID) - throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { - final String METHODNAME = "onMessage".intern(); + - StringBuilder sb = new StringBuilder().append(" Execution Report=(").append(" ExecID=(") - .append(message.getExecID()).append(") SessionID=(").append(sessionID.toString()).append(")"); - log.infoFIXSession(sb.toString(), sessionID, MessageDirection.RECEIVED, METHODNAME, - message.getClass().getSimpleName(), this.instanceType); + @Override + public void send(AlignmentKafkaSender sender) { + final String METHOD = "send".intern(); + + ProducerRecord producerRecord = new ProducerRecord<>(sender.getTopic(), sender.getKey(), sender.getBinaryMessage()); + debugger.debug(CLASSNAME + "." + METHOD); + + this.kafkaProducerB.send(producerRecord); } @Override - public void processMessage(String topicName, ConsumerRecord message) throws Exception { - // TODO Auto-generated method stub + public void processMessage(String topicName, ConsumerRecord consumerRecord) throws Exception { + final String METHOD = "processMessage".intern(); //Here we receive a Kafka Message... - log.info(CLASSNAME + " received " + topicName); - //topicName + log.info(CLASSNAME + "." + METHOD + " received " + topicName); - ByteBuffer bb = ByteBuffer.wrap(message.value()).order(encoding.getByteOrder()); + ByteBuffer bb = ByteBuffer.wrap(consumerRecord.value()).order(encoding.getByteOrder()); final short msgType = bb.getShort(); // buf.putShort(messageType); //When we get to here we know the message type that was used //if its an Order then we need to send acknowledgement @@ -317,6 +381,11 @@ public void processMessage(String topicName, ConsumerRecord mess } - Session.sendToTarget(er); + Boolean sent = Session.sendToTarget(er); + if (sent) { + debugger.info(CLASSNAME + "." + METHOD + " sent on " + topicName); + }else { + debugger.error(CLASSNAME + "." + METHOD + " not sent on " + topicName); + } } } \ No newline at end of file diff --git a/exchange/src/main/java/com/alignmentsystems/matching/FIXEngineKafkaListener.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineKafkaConsumer.java similarity index 73% rename from exchange/src/main/java/com/alignmentsystems/matching/FIXEngineKafkaListener.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineKafkaConsumer.java index 5d4b3a2..f3fca27 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/FIXEngineKafkaListener.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineKafkaConsumer.java @@ -6,7 +6,7 @@ * Date : 24th August 2023 * Copyright : Alignment Systems Ltd 2023 * Project : Alignment Matching Toy - * Artefact : FIXEngineKafkaListener + * Artefact : AlignmentFIXEngineKafkaConsumer * Description : *****************************************************************************/ @@ -23,6 +23,7 @@ import com.alignmentsystems.library.AlignmentFunctions; import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; import com.alignmentsystems.library.enumerations.InstanceType; import com.alignmentsystems.library.interfaces.InterfaceKafkaAbstractSimple; import com.alignmentsystems.library.interfaces.InterfaceKafkaMessageHandler; @@ -31,39 +32,22 @@ * @author John Greenan * */ -public class FIXEngineKafkaListener extends InterfaceKafkaAbstractSimple implements Runnable { - public final static String CLASSNAME = OrderBookKafkaConsumer.class.getSimpleName(); +public class AlignmentFIXEngineKafkaConsumer extends InterfaceKafkaAbstractSimple implements Runnable { + public final static String CLASSNAME = AlignmentFIXEngineKafkaConsumer.class.getSimpleName(); private final int TIME_OUT_MS = 5000; private KafkaConsumer kafkaConsumer = null; private final AtomicBoolean closed = new AtomicBoolean(false); private AlignmentLogEncapsulation log = null; + private AlignmentPersistenceToFileClient debugger = null; private Properties props = null; - public FIXEngineKafkaListener() throws Exception { + public AlignmentFIXEngineKafkaConsumer() throws Exception { super(); // TODO Auto-generated constructor stub } - /** - * - * @param log - * @return - * @throws FileNotFoundException - * @throws NullPointerException - */ - public Boolean initialise(AlignmentLogEncapsulation log) throws FileNotFoundException , NullPointerException{ - this.log = log; - try { - this.props = AlignmentFunctions.getProperties(FIXEngineKafkaListener.class.getClassLoader(), InstanceType.KAFKA.getProperties()); - } catch (FileNotFoundException |NullPointerException e) { - throw e; - } - - return Boolean.TRUE; - } - /** * @@ -85,6 +69,10 @@ public KafkaConsumer getKafkaConsumer() { @Override public void run() { AtomicBoolean run = new AtomicBoolean(true); + + AlignmentUEH ueh = new AlignmentUEH(); + Thread.setDefaultUncaughtExceptionHandler(ueh); + while (run.get()) { try { wait(2000); @@ -110,9 +98,9 @@ public void runAlways(String topicName, InterfaceKafkaMessageHandler callback) t @Override public void runAlways(List topicNames , InterfaceKafkaMessageHandler callback) throws Exception { - Properties props; + try { - props = AlignmentFunctions.getProperties(OrderBookKafkaConsumer.class.getClassLoader() , InstanceType.KAFKA.getProperties()); + this.props = AlignmentFunctions.getProperties(AlignmentFIXEngineKafkaConsumer.class.getClassLoader() , InstanceType.KAFKA.getProperties()); } catch (FileNotFoundException | NullPointerException e) { //log.error(e.getMessage() , e); throw e; @@ -130,6 +118,7 @@ public void runAlways(List topicNames , InterfaceKafkaMessageHandler cal }else { for (ConsumerRecord record : records) { + log.info("Records retrieved - execute callback"); callback.processMessage(record.topic(), record); } } @@ -140,4 +129,25 @@ public void runAlways(List topicNames , InterfaceKafkaMessageHandler cal throw e; } } + + + @Override + public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger) throws FileNotFoundException , NullPointerException{ + final String METHOD = "initialise"; + + this.log = log; + this.debugger = debugger; + + log.info(CLASSNAME + "." + METHOD); + + + try { + this.props = AlignmentFunctions.getProperties(AlignmentFIXEngineKafkaConsumer.class.getClassLoader(), InstanceType.KAFKA.getProperties()); + } catch (FileNotFoundException |NullPointerException e) { + throw e; + } + + return Boolean.TRUE; + + } } \ No newline at end of file diff --git a/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineKafkaProducer.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineKafkaProducer.java new file mode 100644 index 0000000..8003431 --- /dev/null +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXEngineKafkaProducer.java @@ -0,0 +1,104 @@ +package com.alignmentsystems.matching; +/****************************************************************************** + * + * Author : John Greenan + * Contact : sales@alignment-systems.com + * Date : 20th September 2023 + * Copyright : Alignment Systems Ltd 2023 + * Project : Alignment Matching Toy + * Artefact : AlignmentFIXEngineKafkaProducer + * Description : + *****************************************************************************/ + +import java.io.FileNotFoundException; +import java.util.Properties; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerRecord; + +import com.alignmentsystems.library.AlignmentFunctions; +import com.alignmentsystems.library.AlignmentKafkaSender; +import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; +import com.alignmentsystems.library.enumerations.InstanceType; +import com.alignmentsystems.library.interfaces.InterfaceKafkaProducer; +import com.alignmentsystems.library.interfaces.InterfaceOrderSender; +import com.alignmentsystems.matching.AlignmentUEH; + +public class AlignmentFIXEngineKafkaProducer implements InterfaceKafkaProducer, Runnable , InterfaceOrderSender { + public final static String CLASSNAME = AlignmentFIXEngineKafkaProducer.class.getSimpleName(); + private KafkaProducer kafkaProducerB = null; + private AlignmentLogEncapsulation log = null; + private AlignmentPersistenceToFileClient debugger = null; + + + + + + + + protected void send(String topicName, String key, byte[] binaryMessage) { + + // create the ProducerRecord object which will represent the message to the + // Kafka broker. + ProducerRecord producerRecord = new ProducerRecord<>(topicName, key, binaryMessage); + + // Use the helper to create an informative log entry in JSON format + // JsonObject obj = LibraryKafka.getMessageLogEntryJSON(CLASSNAME, topicName, + // key, message); + // log.info(obj.asJsonObject().toString()); + // Send the message to the Kafka broker using the internal + // KafkaProducer + this.kafkaProducerB.send(producerRecord); + } + + + + @Override + public void run() { + AtomicBoolean run = new AtomicBoolean(true); + + while (run.get()) { + try { + wait(2000); + } catch (IllegalArgumentException | InterruptedException | IllegalMonitorStateException e) { + log.error(e.getMessage() , e ); + } + } + + } + + + + @Override + public void send(AlignmentKafkaSender sender) { + this.send(sender.getTopic(), sender.getKey(), sender.getBinaryMessage()); + } + + + + @Override + public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger) + throws FileNotFoundException, NullPointerException { + + this.log = log; + this.debugger = debugger; + + + AlignmentUEH ueh = new AlignmentUEH(this.debugger); + Thread.setDefaultUncaughtExceptionHandler(ueh); + + if (this.kafkaProducerB == null) { + Properties props; + try { + props = AlignmentFunctions.getProperties(AlignmentFIXEngineKafkaProducer.class.getClassLoader(), InstanceType.KAFKA.getProperties()); + } catch (FileNotFoundException | NullPointerException e) { + this.log.error(e.getMessage() , e); + throw e; + } + this.kafkaProducerB = new KafkaProducer<>(props); + } + return true; + } +} \ No newline at end of file diff --git a/exchange/src/main/java/com/alignmentsystems/matching/FIXToBinaryProcessor.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXToBinaryProcessor.java similarity index 83% rename from exchange/src/main/java/com/alignmentsystems/matching/FIXToBinaryProcessor.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXToBinaryProcessor.java index af08c82..5c8ab51 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/FIXToBinaryProcessor.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentFIXToBinaryProcessor.java @@ -22,8 +22,8 @@ * @author John Greenan * */ -public class FIXToBinaryProcessor implements Runnable, InterfaceFIXToBinaryProcessor { - protected final static String CLASSNAME = FIXToBinaryProcessor.class.getSimpleName().toString(); +public class AlignmentFIXToBinaryProcessor implements Runnable, InterfaceFIXToBinaryProcessor { + protected final static String CLASSNAME = AlignmentFIXToBinaryProcessor.class.getSimpleName().toString(); private AlignmentLogEncapsulation log = null; private ConcurrentLinkedQueue inQueue = null; private KafkaProducer kafkaProducerB = null; @@ -31,25 +31,32 @@ public class FIXToBinaryProcessor implements Runnable, InterfaceFIXToBinaryProce private final static int MILLISLEEP = 200; //private static BinaryFromToCanonical binaryFromToCanonical = new BinaryFromToCanonical(); - public FIXToBinaryProcessor() { + public AlignmentFIXToBinaryProcessor() { // TODO Auto-generated constructor stub } @Override public boolean initialise(ConcurrentLinkedQueue inQueue, AlignmentLogEncapsulation log) throws Exception{ + final String METHOD = "initialise"; + + this.inQueue = inQueue; this.log = log; if (this.kafkaProducerB == null) { Properties props; try { - props = AlignmentFunctions.getProperties(FIXToBinaryProcessor.class.getClassLoader(), InstanceType.KAFKA.getProperties()); + props = AlignmentFunctions.getProperties(AlignmentFIXToBinaryProcessor.class.getClassLoader(), InstanceType.KAFKA.getProperties()); } catch (FileNotFoundException | NullPointerException e) { this.log.error(e.getMessage() , e); throw e; } this.kafkaProducerB = new KafkaProducer<>(props); } + + log.info(CLASSNAME + "." + METHOD); + + return true; } @@ -60,6 +67,12 @@ public boolean initialise(ConcurrentLinkedQueue inQueue, Alignme @Override public void run() { running.set(true); + + AlignmentUEH ueh = new AlignmentUEH(); + + Thread.setDefaultUncaughtExceptionHandler(ueh); + + while (running.get()) { @@ -69,6 +82,7 @@ public void run() { AlignmentKafkaSender sender = inSeq.getBytesAsSBEInSender(); this.send(sender.getTopic(), sender.getKey(), sender.getBinaryMessage()); + sender = null; } try { Thread.currentThread(); diff --git a/exchange/src/main/java/com/alignmentsystems/matching/InstanceWrapper.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentInstanceWrapper.java similarity index 54% rename from exchange/src/main/java/com/alignmentsystems/matching/InstanceWrapper.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentInstanceWrapper.java index 59ae00d..57d48ae 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/InstanceWrapper.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentInstanceWrapper.java @@ -4,7 +4,10 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import com.alignmentsystems.fix44.MessageFactory; import com.alignmentsystems.library.AlignmentFunctions; @@ -26,27 +29,27 @@ * @author John Greenan * */ -public class InstanceWrapper implements InterfaceInstanceWrapper { +public class AlignmentInstanceWrapper implements InterfaceInstanceWrapper { private final String CLASSNAME = this.getClass().getSimpleName(); - private List engines = new ArrayList(); + private List engines = new ArrayList(); //private ConcurrentLinkedQueue marketDataQueue = new ConcurrentLinkedQueue(); private InstanceType instanceType; - private final AlignmentLogEncapsulation log = new AlignmentLogEncapsulation(InstanceWrapper.class); + private final AlignmentLogEncapsulation log = new AlignmentLogEncapsulation(AlignmentInstanceWrapper.class); @Override public boolean initialise(InstanceType instanceType) { this.instanceType = instanceType; - + StringBuilder sb = new StringBuilder(); sb.append(CLASSNAME).append(" Started instance=").append(this.instanceType.type).append(" Started version=") - .append(AlignmentFunctions.getVersion(this.getClass())); + .append(AlignmentFunctions.getVersion(this.getClass())); Boolean returnValue = Boolean.FALSE; log.info(sb.toString()); - + log.showSystemProperties(); // What do we do here? @@ -54,9 +57,12 @@ public boolean initialise(InstanceType instanceType) { // a FIXMESSAGINGINFRA; // b ORDERBOOK; // Then there is a clear segregation of duties. - //FIXMESSAGINGINFRA handles the FIX Connections, the non-sequenced queue, the sequenced queue, the AlignmentDataMapper and the FIXToBinaryProcessor + //FIXMESSAGINGINFRA handles the FIX Connections, the non-sequenced queue, the sequenced queue, the AlignmentDataMapper and the AlignmentFIXToBinaryProcessor // + + + switch (instanceType) { case FIXMESSAGINGINFRA: @@ -69,30 +75,41 @@ public boolean initialise(InstanceType instanceType) { returnValue = false; break; } - while (returnValue) { -// try { -// //wait(2000); -// } catch (InterruptedException e) { -// log.error(e.getMessage() , e ); -// } - } - return returnValue; - - + while (returnValue) { + try { + wait(2000); + } catch (InterruptedException e) { + log.error(e.getMessage() , e ); + } + } + return returnValue; + + } private Boolean initialiseOrderBook(InstanceType instanceType) { - + final String METHOD = "initialiseOrderBook"; + + + AlignmentPersistenceToFileClient debugger = new AlignmentPersistenceToFileClient(); + + try { - debugger.initialise(InstanceWrapper.class.getClassLoader(), InstanceType.ORDERBOOK.getProperties()); + debugger.initialise(AlignmentInstanceWrapper.class.getClassLoader(), InstanceType.ORDERBOOK.getProperties()); debugger.info("Working..."); } catch (IllegalThreadStateException | IOException e) { log.error(e.getMessage(), e); return false; } - - OrderBookWrapper obw = new OrderBookWrapper(); + + AlignmentUEH ueh = new AlignmentUEH(debugger); + + Thread.setDefaultUncaughtExceptionHandler(ueh); + + + + AlignmentOrderBookWrapper obw = new AlignmentOrderBookWrapper(); try { obw.initialise(this.log, debugger); @@ -100,99 +117,162 @@ private Boolean initialiseOrderBook(InstanceType instanceType) { log.error(e.getMessage(), e); return false; } - + Thread.currentThread().setName(instanceType.toString()); - - + + return true; } private Boolean initialiseFIXMessagingInfrastructure(InstanceType instanceType) { + final String METHOD = "initialiseFIXMessagingInfrastructure"; + AlignmentPersistenceToFileClient debugger = new AlignmentPersistenceToFileClient(); try { debugger.initialise(this.getClass().getClassLoader() , InstanceType.FIXMESSAGINGINFRA.getProperties()); - debugger.info("Working..."); + debugger.info(CLASSNAME + "." + METHOD); } catch (IllegalThreadStateException | IOException e) { log.error(e.getMessage(), e); return false; } - QueueNonSequenced queueNonSequenced = new QueueNonSequenced(); - Thread queueNonSequencedThread = new Thread(null, queueNonSequenced, QueueNonSequenced.CLASSNAME); + AlignmentUEH ueh = new AlignmentUEH(debugger); + Thread.setDefaultUncaughtExceptionHandler(ueh); + + + AlignmentQueueNonSequenced queueNonSequenced = new AlignmentQueueNonSequenced(); + Thread threadQueueNonSequenced = new Thread(null, queueNonSequenced, AlignmentQueueNonSequenced.CLASSNAME); queueNonSequenced.initialise(log); - QueueSequenced queueSequenced = new QueueSequenced(); - Thread queueSequencedThread = new Thread(null, queueSequenced, QueueSequenced.CLASSNAME); + AlignmentQueueSequenced queueSequenced = new AlignmentQueueSequenced(); + Thread threadQueueSequenced = new Thread(null, queueSequenced, AlignmentQueueSequenced.CLASSNAME); queueSequenced.initialise(queueNonSequenced.getOutputQueue()); - FIXToBinaryProcessor fixToBinaryProcessor = new FIXToBinaryProcessor(); + AlignmentFIXToBinaryProcessor fixToBinaryProcessor = new AlignmentFIXToBinaryProcessor(); try { fixToBinaryProcessor.initialise(queueSequenced.getOutputQueue() , log); } catch (Exception e) { log.error(e.getMessage(), e); return false; } - - Thread fixToBinaryProcessorThread = new Thread(null, fixToBinaryProcessor, FIXToBinaryProcessor.CLASSNAME); - - - Thread.currentThread().setName(instanceType.type ); - fixToBinaryProcessorThread.start(); - queueSequencedThread.start(); - queueNonSequencedThread.start(); + Thread threadFixToBinaryProcessor = new Thread(null, fixToBinaryProcessor, AlignmentFIXToBinaryProcessor.CLASSNAME); + + + AlignmentFIXEngineKafkaConsumer fixEngineKafkaConsumer = null; - FIXEngineKafkaListener fixEngineKafkaListener = null; - try { - fixEngineKafkaListener = new FIXEngineKafkaListener(); + fixEngineKafkaConsumer = new AlignmentFIXEngineKafkaConsumer(); } catch (Exception e) { log.error(e.getMessage(), e); return false; } try { - fixEngineKafkaListener.initialise(log); + fixEngineKafkaConsumer.initialise(log, debugger); } catch (NullPointerException | FileNotFoundException e) { log.error(e.getMessage(), e); return false; } - - - - FIXEngineExchange engineExchange = new FIXEngineExchange(log , queueNonSequenced , InstanceType.EXCHANGEFIXACCEPTOR); - engines.add(engineExchange); - String[] acceptors = { InstanceType.EXCHANGEFIXACCEPTOR.getProperties() }; - log.debug("get" + acceptors[0]); + AlignmentFIXEngineKafkaProducer fixEngineKafkaProducer = null; - final List messagesToSendToFIXEngine = List.of("fill","ack","rej"); - - try { - fixEngineKafkaListener.runAlways(messagesToSendToFIXEngine, engineExchange); + fixEngineKafkaProducer = new AlignmentFIXEngineKafkaProducer(); } catch (Exception e) { log.error(e.getMessage(), e); return false; } + + try { + fixEngineKafkaProducer.initialise(this.log, debugger); + } catch (NullPointerException | FileNotFoundException e) { + log.error(e.getMessage(), e); + return false; + } + + Thread ThreadFixEngineKafkaProducer = new Thread(null, fixEngineKafkaProducer, AlignmentFIXEngineKafkaProducer.CLASSNAME); + + + try { + debugger.debug("Start threads"); + Thread.currentThread().setName(instanceType.type ); + + threadFixToBinaryProcessor.start(); + threadQueueSequenced.start(); + threadQueueNonSequenced.start(); + + ThreadFixEngineKafkaProducer.start(); + }catch (IllegalThreadStateException e) { + log.error(e.getMessage(), e); + return false; + + } + + + AlignmentFIXEngineExchange engineExchange = new AlignmentFIXEngineExchange(); + try { + debugger.debug("Initialise FIX engine"); + engineExchange.initialise(log , debugger , instanceType ); + engines.add(engineExchange); + } catch (FileNotFoundException | NullPointerException e) { + log.error(e.getMessage(), e); + return false; + } + + final String[] acceptors = { InstanceType.EXCHANGEFIXACCEPTOR.getProperties() }; + - - + debugger.debug("get" + acceptors[0]); + + Acceptor exchange = null; try { + debugger.debug("Request start FIX engine"); exchange = getExchangeEnvironment(acceptors[0], engineExchange); - } catch (NullPointerException e) { + exchange.start(); + debugger.debug("Requested start FIX engine"); + } catch (NullPointerException | RuntimeError | ConfigError e) { log.error(e.getMessage(), e); System.err.println(e.getMessage()); System.exit(FailureConditionConstants.ERROR_EXCHANGE_FIX_PROPERTIES_FILE); } - AlignmentFunctions.threadStatusCheck(Thread.currentThread(), log); - AlignmentFunctions.threadStatusCheck(queueNonSequencedThread, log); - AlignmentFunctions.threadStatusCheck(queueSequencedThread, log); - AlignmentFunctions.threadStatusCheck(fixToBinaryProcessorThread, log); + debugger.debug("Request list threads"); + Set threadSet = Thread.getAllStackTraces().keySet(); + + + Iterator namesIterator = threadSet.iterator(); + while(namesIterator.hasNext()) { + AlignmentFunctions.threadStatusCheck(namesIterator.next(), debugger); + } + + final List messagesToBeReceivedByFIXEngine = List.of("fill","ack","rej"); + + + try { + debugger.debug("Start KafkaConsumer"); + fixEngineKafkaConsumer.runAlways(messagesToBeReceivedByFIXEngine, engineExchange); + debugger.debug("Started KafkaConsumer"); + } catch (Exception e) { + log.error(e.getMessage(), e); + return false; + } + AtomicBoolean run = new AtomicBoolean(true); + + while (run.get()) { + try { + wait(2000); + } catch (InterruptedException e) { + log.error(e.getMessage() , e ); + } + } + + + + return true; } @@ -203,10 +283,10 @@ private Boolean initialiseFIXMessagingInfrastructure(InstanceType instanceType) * @return * @throws NullPointerException */ - private static Acceptor getExchangeEnvironment(String configFile, FIXEngineExchange engine) + private static Acceptor getExchangeEnvironment(String configFile, AlignmentFIXEngineExchange engine) throws NullPointerException { - InputStream inputStream = App.class.getClassLoader().getResourceAsStream(configFile); + InputStream inputStream = AlignmentApp.class.getClassLoader().getResourceAsStream(configFile); if (inputStream == null) { throw new NullPointerException("No valid config file at " + configFile); @@ -223,7 +303,6 @@ private static Acceptor getExchangeEnvironment(String configFile, FIXEngineExcha acceptor = new SocketAcceptor(engine, messageStoreFactory, settings, logFactory, messageFactory); - acceptor.start(); } catch (ConfigError e) { System.err.println(e.getMessage()); diff --git a/exchange/src/main/java/com/alignmentsystems/matching/KafkaLibrary.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentKafkaLibrary.java similarity index 86% rename from exchange/src/main/java/com/alignmentsystems/matching/KafkaLibrary.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentKafkaLibrary.java index 3932cd5..6e96d78 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/KafkaLibrary.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentKafkaLibrary.java @@ -23,12 +23,12 @@ * @author John Greenan * */ -public class KafkaLibrary { +public class AlignmentKafkaLibrary { public static JsonObject getMessageLogEntryJSON(String source, String topic, String key, String message) throws Exception { - String bootstrapServers = AlignmentFunctions.getProperty(KafkaLibrary.class.getClassLoader(), InstanceType.KAFKA.getProperties(), + String bootstrapServers = AlignmentFunctions.getProperty(AlignmentKafkaLibrary.class.getClassLoader(), InstanceType.KAFKA.getProperties(), ConfigurationProperties.BOOTSTRAPSERVERS); JsonObject model = Json.createObjectBuilder().add("bootstrapServers", bootstrapServers).add("source", source) diff --git a/exchange/src/main/java/com/alignmentsystems/matching/OrderBook.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBook.java similarity index 98% rename from exchange/src/main/java/com/alignmentsystems/matching/OrderBook.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBook.java index e8665d7..b36ad78 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/OrderBook.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBook.java @@ -7,7 +7,7 @@ * Date : 24th August 2023 * Copyright : Alignment Systems Ltd 2023 * Project : Alignment Matching Toy - * Artefact : OrderBook + * Artefact : AlignmentOrderBook * Description : *****************************************************************************/ @@ -49,9 +49,9 @@ * "https://kafka.apache.org/35/javadoc/org/apache/kafka/clients/consumer/package-summary.html">Consumer * */ -public class OrderBook +public class AlignmentOrderBook implements InterfaceKafkaMessageHandler, InterfaceOrderBook, InterfaceMatchEvent, InterfaceAddedOrderToOrderBook, InterfaceOrderBookEvents, Runnable { - private final static String CLASSNAME = OrderBook.class.getSimpleName(); + private final static String CLASSNAME = AlignmentOrderBook.class.getSimpleName(); private final static int buyPriorityQueueSize = 100; private final static int sellPriorityQueueSize = 100; @@ -77,15 +77,17 @@ public class OrderBook @Override public Boolean initialise(String symbol, AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger, InterfaceMatchEvent toAddMatch, InterfaceAddedOrderToOrderBook toAddOrder) { + final String METHOD = "initialise"; + Boolean returnValue = Boolean.FALSE; this.orderBookCreationTime = OffsetDateTime.now(Constants.HERE); this.symbol = symbol; this.log = log; this.debugger = debugger; - this.addMatchEventListener(toAddMatch); this.addAddedOrderToOrderBookListener(toAddOrder); + debugger.info(CLASSNAME + "." + METHOD); returnValue = Boolean.TRUE; diff --git a/exchange/src/main/java/com/alignmentsystems/matching/OrderBookKafkaConsumer.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookKafkaConsumer.java similarity index 81% rename from exchange/src/main/java/com/alignmentsystems/matching/OrderBookKafkaConsumer.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookKafkaConsumer.java index 1fcf3bf..cee9643 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/OrderBookKafkaConsumer.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookKafkaConsumer.java @@ -6,7 +6,7 @@ * Date : 13th September 2023 * Copyright : Alignment Systems Ltd 2023 * Project : Alignment Matching Toy - * Artefact : OrderBookKafkaConsumer + * Artefact : AlignmentOrderBookKafkaConsumer * Description : *****************************************************************************/ @@ -26,37 +26,49 @@ import com.alignmentsystems.library.AlignmentFunctions; import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; import com.alignmentsystems.library.enumerations.InstanceType; import com.alignmentsystems.library.interfaces.InterfaceKafkaAbstractSimple; import com.alignmentsystems.library.interfaces.InterfaceKafkaMessageHandler; -public class OrderBookKafkaConsumer extends InterfaceKafkaAbstractSimple implements Runnable{ - public final static String CLASSNAME = OrderBookKafkaConsumer.class.getSimpleName(); +public class AlignmentOrderBookKafkaConsumer extends InterfaceKafkaAbstractSimple implements Runnable{ + public final static String CLASSNAME = AlignmentOrderBookKafkaConsumer.class.getSimpleName(); + private final int TIME_OUT_MS = 5000; private KafkaConsumer kafkaConsumer = null; private final AtomicBoolean closed = new AtomicBoolean(false); private AlignmentLogEncapsulation log = null; + private AlignmentPersistenceToFileClient debugger = null; + private Properties props = null; - public OrderBookKafkaConsumer() throws Exception { + public AlignmentOrderBookKafkaConsumer() throws Exception { super(); // TODO Auto-generated constructor stub } - public Boolean initialise(AlignmentLogEncapsulation log) throws FileNotFoundException , NullPointerException{ + @Override + public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger) throws FileNotFoundException , NullPointerException{ + final String METHOD = "initialise"; + + this.log = log; + this.debugger = debugger; + + log.info(CLASSNAME + "." + METHOD); + try { - props = AlignmentFunctions.getProperties(OrderBookKafkaConsumer.class.getClassLoader(), InstanceType.KAFKA.getProperties()); - } catch (FileNotFoundException |NullPointerException e) { + this.props = AlignmentFunctions.getProperties(AlignmentFIXEngineKafkaConsumer.class.getClassLoader(), InstanceType.KAFKA.getProperties()); + } catch (FileNotFoundException |NullPointerException e) { throw e; } return Boolean.TRUE; - } + } public void setKafkaConsumer(KafkaConsumer kafkaConsumer) { this.kafkaConsumer = kafkaConsumer; } @@ -142,7 +154,7 @@ public void runAlways(List topicNames, InterfaceKafkaMessageHandler call Properties props; try { - props = AlignmentFunctions.getProperties(OrderBookKafkaConsumer.class.getClassLoader() , InstanceType.KAFKA.getProperties()); + props = AlignmentFunctions.getProperties(AlignmentOrderBookKafkaConsumer.class.getClassLoader() , InstanceType.KAFKA.getProperties()); } catch (FileNotFoundException | NullPointerException e) { //log.error(e.getMessage() , e); throw e; diff --git a/exchange/src/main/java/com/alignmentsystems/matching/OrderBookKafkaProducer.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookKafkaProducer.java similarity index 79% rename from exchange/src/main/java/com/alignmentsystems/matching/OrderBookKafkaProducer.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookKafkaProducer.java index 6c43044..55adb8b 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/OrderBookKafkaProducer.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookKafkaProducer.java @@ -6,7 +6,7 @@ * Date : 17th September 2023 * Copyright : Alignment Systems Ltd 2023 * Project : Alignment Matching Toy - * Artefact : OrderBookKafkaProducer + * Artefact : AlignmentOrderBookKafkaProducer * Description : *****************************************************************************/ @@ -22,17 +22,20 @@ import com.alignmentsystems.library.AlignmentKafkaSender; import com.alignmentsystems.library.AlignmentFunctions; import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; import com.alignmentsystems.library.enumerations.InstanceType; import com.alignmentsystems.library.enumerations.OperationEventType; import com.alignmentsystems.library.interfaces.InterfaceAddedOrderToOrderBook; import com.alignmentsystems.library.interfaces.InterfaceExecutionReport; +import com.alignmentsystems.library.interfaces.InterfaceKafkaProducer; import com.alignmentsystems.library.interfaces.InterfaceMatch; import com.alignmentsystems.library.interfaces.InterfaceMatchEvent; import com.alignmentsystems.library.interfaces.InterfaceOrderBookEvents; -public class OrderBookKafkaProducer implements InterfaceMatchEvent, InterfaceAddedOrderToOrderBook, InterfaceOrderBookEvents, Runnable { +public class AlignmentOrderBookKafkaProducer implements InterfaceKafkaProducer, InterfaceMatchEvent, InterfaceAddedOrderToOrderBook, InterfaceOrderBookEvents, Runnable { private KafkaProducer kafkaProducerB = null; private AlignmentLogEncapsulation log = null; + private AlignmentPersistenceToFileClient debugger = null; private List listenersMatchEvent = new ArrayList(); private List listenersAddedOrderToOrderBook = new ArrayList(); @@ -41,35 +44,12 @@ public class OrderBookKafkaProducer implements InterfaceMatchEvent, InterfaceAdd public void addAddedOrderToOrderBookListener(InterfaceAddedOrderToOrderBook toAdd) { this.listenersAddedOrderToOrderBook.add(toAdd); } - + @Override public void addMatchEventListener(InterfaceMatchEvent toAdd) { this.listenersMatchEvent.add(toAdd); } - public OrderBookKafkaProducer() { - // TODO Auto-generated constructor stub - } - - - public boolean initialise(AlignmentLogEncapsulation log) throws Exception{ - - this.log = log; - - if (this.kafkaProducerB == null) { - Properties props; - try { - props = AlignmentFunctions.getProperties(FIXToBinaryProcessor.class.getClassLoader(), InstanceType.KAFKA.getProperties()); - } catch (FileNotFoundException | NullPointerException e) { - this.log.error(e.getMessage() , e); - throw e; - } - this.kafkaProducerB = new KafkaProducer<>(props); - } - return true; - } - - protected void send(String topicName, String key, byte[] binaryMessage) { @@ -92,10 +72,12 @@ protected void send(String topicName, String key, byte[] binaryMessage) { public void run() { AtomicBoolean run = new AtomicBoolean(true); while (run.get()) { - try { - wait(2000); - } catch (InterruptedException e) { - log.error(e.getMessage() , e ); + while (run.get()) { + try { + wait(2000); + } catch (IllegalArgumentException | InterruptedException | IllegalMonitorStateException e) { + log.error(e.getMessage() , e ); + } } } @@ -112,7 +94,7 @@ public void matchHappened(InterfaceMatch match) { AlignmentKafkaSender senderBuy = match.getBuyReport().getSenderForTopic(TOPIC); AlignmentKafkaSender senderSell = match.getSellReport().getSenderForTopic(TOPIC); - + this.send(senderBuy.getTopic() , senderBuy.getKey(), senderBuy.getBinaryMessage()); this.send(senderSell.getTopic() , senderSell.getKey(), senderSell.getBinaryMessage()); } @@ -125,7 +107,31 @@ public void addedOrderToOrderBook(InterfaceExecutionReport er) { //log.infoMatchingEvent(OperationEventType.NEWORDEREVENT, er); AlignmentKafkaSender senderAck= er.getSenderForTopic(TOPIC); - + this.send(senderAck.getTopic(), senderAck.getKey(), senderAck.getBinaryMessage()); } + + @Override + public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger) + throws FileNotFoundException, NullPointerException { + this.log = log; + this.debugger = debugger; + AlignmentUEH ueh = new AlignmentUEH(this.debugger); + Thread.setDefaultUncaughtExceptionHandler(ueh); + + + + if (this.kafkaProducerB == null) { + Properties props; + try { + props = AlignmentFunctions.getProperties(AlignmentFIXToBinaryProcessor.class.getClassLoader(), InstanceType.KAFKA.getProperties()); + } catch (FileNotFoundException | NullPointerException e) { + this.log.error(e.getMessage() , e); + throw e; + } + this.kafkaProducerB = new KafkaProducer<>(props); + } + return true; + + } } \ No newline at end of file diff --git a/exchange/src/main/java/com/alignmentsystems/matching/OrderBookWrapper.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookWrapper.java similarity index 75% rename from exchange/src/main/java/com/alignmentsystems/matching/OrderBookWrapper.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookWrapper.java index 9cbdb53..5fe098b 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/OrderBookWrapper.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentOrderBookWrapper.java @@ -12,9 +12,8 @@ * @author John Greenan * */ -public class OrderBookWrapper implements InterfaceOrderBookWrapper{ - @SuppressWarnings("unused") - private final static String CLASSNAME = OrderBookWrapper.class.getSimpleName(); +public class AlignmentOrderBookWrapper implements InterfaceOrderBookWrapper{ + public final static String CLASSNAME = AlignmentOrderBookWrapper.class.getSimpleName(); private Map orderBooks = new HashMap(); private AlignmentLogEncapsulation log = null; @@ -36,16 +35,21 @@ public String toString() { @Override public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger) throws Exception { + final String METHOD = "initialise"; + this.log = log; this.debugger = debugger; + debugger.info(CLASSNAME + "." + METHOD); + + final String symbol = "BADGER.W"; - OrderBook orderBook = new OrderBook(); + AlignmentOrderBook orderBook = new AlignmentOrderBook(); - OrderBookKafkaProducer obkp = new OrderBookKafkaProducer(); + AlignmentOrderBookKafkaProducer obkp = new AlignmentOrderBookKafkaProducer(); - obkp.initialise(log); + obkp.initialise(this.log , this.debugger ); if(orderBook.initialise(symbol, this.log, this.debugger, obkp, obkp)) { @@ -63,12 +67,12 @@ public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToF obThread.start(); - OrderBookKafkaConsumer obkc = null; + AlignmentOrderBookKafkaConsumer obkc = null; try { - obkc = new OrderBookKafkaConsumer(); - Thread obkThread = new Thread(null, obkc, OrderBookKafkaConsumer.CLASSNAME); - obkc.initialise(this.log); + obkc = new AlignmentOrderBookKafkaConsumer(); + Thread obkThread = new Thread(null, obkc, AlignmentOrderBookKafkaConsumer.CLASSNAME); + obkc.initialise(this.log, debugger); obkThread.start(); } catch (Exception e) { //log.error(e.getMessage() , e); diff --git a/exchange/src/main/java/com/alignmentsystems/matching/QueueNonSequenced.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentQueueNonSequenced.java similarity index 80% rename from exchange/src/main/java/com/alignmentsystems/matching/QueueNonSequenced.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentQueueNonSequenced.java index 7ad8677..1af5425 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/QueueNonSequenced.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentQueueNonSequenced.java @@ -7,7 +7,7 @@ * Date : 24th August 2023 * Copyright : Alignment Systems Ltd 2023 * Project : Alignment Matching Toy - * Artefact : QueueNonSequenced + * Artefact : AlignmentQueueNonSequenced * Description : *****************************************************************************/ @@ -23,9 +23,10 @@ * @author John Greenan * */ -public class QueueNonSequenced implements Runnable, InterfaceQueueNonSequenced { - protected final static String CLASSNAME = QueueNonSequenced.class.getSimpleName().toString(); +public class AlignmentQueueNonSequenced implements Runnable, InterfaceQueueNonSequenced { + protected final static String CLASSNAME = AlignmentQueueNonSequenced.class.getSimpleName().toString(); private ConcurrentLinkedQueue nonSequencedIn; + @SuppressWarnings("unused") private AlignmentLogEncapsulation log = null; private final static int MILLISLEEP = 200; private AtomicBoolean running = new AtomicBoolean(false); @@ -33,6 +34,12 @@ public class QueueNonSequenced implements Runnable, InterfaceQueueNonSequenced { @Override public void run() { + + AlignmentUEH ueh = new AlignmentUEH(); + + Thread.setDefaultUncaughtExceptionHandler(ueh); + + running.set(true); while (running.get()) { @@ -63,9 +70,17 @@ public boolean addReceivedOrder(InterfaceOrder io) { @Override public boolean initialise(AlignmentLogEncapsulation log) { + final String METHOD = "initialise"; + + this.log = log; + + if (!initialised.get()) { - this.log = log; + this.nonSequencedIn = new ConcurrentLinkedQueue (); + + log.info(CLASSNAME + "." + METHOD); + initialised.set(true); } return initialised.get(); diff --git a/exchange/src/main/java/com/alignmentsystems/matching/QueueSequenced.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentQueueSequenced.java similarity index 83% rename from exchange/src/main/java/com/alignmentsystems/matching/QueueSequenced.java rename to exchange/src/main/java/com/alignmentsystems/matching/AlignmentQueueSequenced.java index 309b3f0..a0271f2 100644 --- a/exchange/src/main/java/com/alignmentsystems/matching/QueueSequenced.java +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentQueueSequenced.java @@ -6,7 +6,7 @@ * Date : 31st August 2023 * Copyright : Alignment Systems Ltd 2023 * Project : Alignment Matching Toy - * Artefact : QueueSequenced + * Artefact : AlignmentQueueSequenced * Description : *****************************************************************************/ @@ -24,8 +24,8 @@ * @author John Greenan * */ -public class QueueSequenced implements Runnable, InterfaceQueueSequencedDeduplicated { - protected final static String CLASSNAME = QueueSequenced.class.getSimpleName().toString(); +public class AlignmentQueueSequenced implements Runnable, InterfaceQueueSequencedDeduplicated { + protected final static String CLASSNAME = AlignmentQueueSequenced.class.getSimpleName().toString(); private ConcurrentLinkedQueue inQueue; private ConcurrentLinkedQueue outQueue; private final int milliSleep = 200; @@ -37,11 +37,11 @@ public class QueueSequenced implements Runnable, InterfaceQueueSequencedDeduplic private HashSet seen = new HashSet(initialCapacityHashSet, loadFactorHashSet); private List deDupedOrders = new ArrayList(arrayListSize); - public QueueSequenced() { + public AlignmentQueueSequenced() { // TODO Auto-generated constructor stub } - + @Override public void run() { @@ -94,8 +94,17 @@ public ConcurrentLinkedQueue getOutputQueue() { @Override public boolean initialise(ConcurrentLinkedQueue inQueue) { - this.inQueue = inQueue; - this.outQueue = new ConcurrentLinkedQueue(); - return true; - } + final String METHOD = "initialise"; + + this.inQueue = inQueue; + this.outQueue = new ConcurrentLinkedQueue(); + //log.info(CLASSNAME + "." + METHOD); + + AlignmentUEH ueh = new AlignmentUEH(); + + Thread.setDefaultUncaughtExceptionHandler(ueh); + + + return true; + } } \ No newline at end of file diff --git a/exchange/src/main/java/com/alignmentsystems/matching/AlignmentUEH.java b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentUEH.java new file mode 100644 index 0000000..41e8c33 --- /dev/null +++ b/exchange/src/main/java/com/alignmentsystems/matching/AlignmentUEH.java @@ -0,0 +1,38 @@ +package com.alignmentsystems.matching; +/****************************************************************************** + * + * Author : John Greenan + * Contact : sales@alignment-systems.com + * Date : 20th September 2023 + * Copyright : Alignment Systems Ltd 2023 + * Project : Alignment Matching Toy + * Artefact : AlignmentUEH + * Description : + *****************************************************************************/ + +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; + +public class AlignmentUEH implements Thread.UncaughtExceptionHandler{ + protected final static String CLASSNAME = AlignmentUEH.class.getSimpleName().toString(); + + private AlignmentPersistenceToFileClient debugger; + private Boolean hasDebugger = Boolean.FALSE; + + public AlignmentUEH() { + this.hasDebugger = false; + } + + public AlignmentUEH(AlignmentPersistenceToFileClient debugger) { + this.debugger = debugger; + this.hasDebugger = true; + } + + @Override + public void uncaughtException(Thread t, Throwable e) { + if (hasDebugger) { + debugger.error(t.getName(), e); + }else { + System.err.println(t.getName() + " " + CLASSNAME); + } + } +} \ No newline at end of file diff --git a/exchange/version.properties b/exchange/version.properties index bf6f003..1be8fb0 100644 --- a/exchange/version.properties +++ b/exchange/version.properties @@ -1,2 +1,2 @@ -#Tue Sep 19 20:48:23 AEST 2023 -VERSION_BUILD=752 +#Wed Sep 20 19:01:38 AEST 2023 +VERSION_BUILD=779 diff --git a/fixclient/version.properties b/fixclient/version.properties index 637c6b0..a805c54 100644 --- a/fixclient/version.properties +++ b/fixclient/version.properties @@ -1,2 +1,2 @@ -#Tue Sep 19 20:48:23 AEST 2023 -VERSION_BUILD=754 +#Wed Sep 20 19:01:38 AEST 2023 +VERSION_BUILD=781 diff --git a/multicastserver/src/main/java/com/alignmentsystems/multicast/MulticastServerKafkaListener.java b/multicastserver/src/main/java/com/alignmentsystems/multicast/MulticastServerKafkaListener.java index dacc731..4f5a263 100644 --- a/multicastserver/src/main/java/com/alignmentsystems/multicast/MulticastServerKafkaListener.java +++ b/multicastserver/src/main/java/com/alignmentsystems/multicast/MulticastServerKafkaListener.java @@ -23,6 +23,7 @@ import com.alignmentsystems.library.AlignmentFunctions; import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; import com.alignmentsystems.library.enumerations.InstanceType; import com.alignmentsystems.library.interfaces.InterfaceKafkaAbstractSimple; import com.alignmentsystems.library.interfaces.InterfaceKafkaMessageHandler; @@ -38,33 +39,12 @@ public class MulticastServerKafkaListener extends InterfaceKafkaAbstractSimple i private final AtomicBoolean closed = new AtomicBoolean(false); private AlignmentLogEncapsulation log = null; private Properties props = null; + private AlignmentPersistenceToFileClient debugger = null; public MulticastServerKafkaListener() throws Exception { super(); // TODO Auto-generated constructor stub } - - - /** - * - * @param log - * @return - * @throws FileNotFoundException - * @throws NullPointerException - */ - public Boolean initialise(AlignmentLogEncapsulation log) throws FileNotFoundException , NullPointerException{ - this.log = log; - - try { - this.props = AlignmentFunctions.getProperties(MulticastServerKafkaListener.class.getClassLoader(), InstanceType.KAFKA.getProperties()); - } catch (FileNotFoundException |NullPointerException e) { - throw e; - } - - return Boolean.TRUE; - } - - /** * * @param kafkaConsumer @@ -140,4 +120,20 @@ public void runAlways(List topicNames , InterfaceKafkaMessageHandler cal throw e; } } + + + @Override + public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger) + throws FileNotFoundException, NullPointerException { + this.log = log; + this.debugger = debugger; + + try { + this.props = AlignmentFunctions.getProperties(MulticastServerKafkaListener.class.getClassLoader(), InstanceType.KAFKA.getProperties()); + } catch (FileNotFoundException |NullPointerException e) { + throw e; + } + + return Boolean.TRUE; + } } \ No newline at end of file diff --git a/multicastserver/version.properties b/multicastserver/version.properties index 637c6b0..a805c54 100644 --- a/multicastserver/version.properties +++ b/multicastserver/version.properties @@ -1,2 +1,2 @@ -#Tue Sep 19 20:48:23 AEST 2023 -VERSION_BUILD=754 +#Wed Sep 20 19:01:38 AEST 2023 +VERSION_BUILD=781 diff --git a/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentFunctions.java b/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentFunctions.java index 74cccd8..d686c80 100644 --- a/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentFunctions.java +++ b/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentFunctions.java @@ -434,7 +434,31 @@ public static void threadStatusCheck(Thread thread, Logger log) { } } + + + /** + * + * @param thread + * @param debugger + */ + public static void threadStatusCheck(Thread thread, AlignmentPersistenceToFileClient debugger) { + String statusMessage = new StringBuilder() + .append(thread.getName()) + .append(Constants.SPACE) + .append(thread.getClass().getSimpleName().toString()) + .append(" is alive?=") + .append(Boolean.toString(thread.isAlive()).toUpperCase()) + .toString() + ; + if (thread.isAlive()){ + debugger.info(statusMessage); + }else { + debugger.error(statusMessage); + } + + + } @@ -443,6 +467,11 @@ public static void threadStatusCheck(Thread thread, Logger log) { +/** + * + * @param classVersionToTest + * @return + */ public final static String getVersionWithTitle(Class classVersionToTest) { final String version = "Version="; final String codeValue = getVersion(classVersionToTest); @@ -565,9 +594,4 @@ private static void showLicense() { System.out.println("Products derived from this software may not be called \"QuickFIX\", nor may \"QuickFIX\" appear in their name, without prior written permission of quickfixengine.org"); System.out.println("THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL QUICKFIXENGINE.ORG OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."); } - - - - - } \ No newline at end of file diff --git a/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentOrder.java b/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentOrder.java index ed75ac7..16b8cb3 100644 --- a/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentOrder.java +++ b/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentOrder.java @@ -409,7 +409,4 @@ public InterfaceOrder getAlignmentOrderFromBuffer(byte[] message) { final short msgType = bb.getShort(); // buf.putShort(messageType return getAlignmentOrderFromBuffer(bb.array(), msgType); } - - - } \ No newline at end of file diff --git a/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentPersistenceToFileClient.java b/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentPersistenceToFileClient.java index 0f78369..6854810 100644 --- a/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentPersistenceToFileClient.java +++ b/sharedlibrary/src/main/java/com/alignmentsystems/library/AlignmentPersistenceToFileClient.java @@ -29,7 +29,6 @@ */ public class AlignmentPersistenceToFileClient implements InterfacePersistenceClient{ private ConcurrentLinkedQueue logQueue = new ConcurrentLinkedQueue(); - private Boolean runOnce = Boolean.TRUE; private final static int MILLISLEEP = 200; private AtomicBoolean hasExecutedInit = new AtomicBoolean(false); private Thread logger = null; @@ -306,7 +305,7 @@ public Boolean error(String toLog) throws LogMessageIsNull { @Experimental @Override - public Boolean error(String toLog, Exception e) throws LogMessageIsNull{ + public Boolean error(String toLog, Throwable t) throws LogMessageIsNull{ Boolean returnValue = Boolean.FALSE; @@ -325,15 +324,13 @@ public Boolean error(String toLog, Exception e) throws LogMessageIsNull{ }else { - StackTraceElement[] stackTrace = e.getStackTrace(); + StackTraceElement[] stackTrace = t.getStackTrace(); for (StackTraceElement element : stackTrace) { returnValue = logExecute(new StringBuilder().append(PersistenceRecordType.ERROR.recordType).append(element.toString()).toString()); - if (!returnValue) {return returnValue;} } returnValue = logExecute(blocker ); - - return returnValue; } + return returnValue; } } @@ -341,7 +338,7 @@ public Boolean error(String toLog, Exception e) throws LogMessageIsNull{ @Override @Experimental - public Boolean errorSession(String toLog, String methodName, Exception e) throws LogMessageIsNull { + public Boolean errorSession(String toLog, String methodName, Throwable t) throws LogMessageIsNull { Boolean returnValue = Boolean.FALSE; @@ -358,7 +355,7 @@ public Boolean errorSession(String toLog, String methodName, Exception e) throws return returnValue; }else { - StackTraceElement[] stackTrace = e.getStackTrace(); + StackTraceElement[] stackTrace = t.getStackTrace(); for (StackTraceElement element : stackTrace) { returnValue = logExecute(PersistenceRecordType.ERROR.recordType + element.toString()); if (!returnValue) {return returnValue;} diff --git a/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceFIXEngine.java b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceFIXEngine.java index cf39bff..ed2a3fc 100644 --- a/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceFIXEngine.java +++ b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceFIXEngine.java @@ -1,9 +1,21 @@ package com.alignmentsystems.library.interfaces; +/****************************************************************************** + * + * Author : John Greenan + * Contact : sales@alignment-systems.com + * Date : 20th September 2023 + * Copyright : Alignment Systems Ltd 2023 + * Project : Alignment Matching Toy + * Artefact : InterfaceFIXEngine + * Description : + *****************************************************************************/ -import quickfix.Acceptor; -import quickfix.Initiator; +import java.io.FileNotFoundException; + +import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; +import com.alignmentsystems.library.enumerations.InstanceType; public interface InterfaceFIXEngine { - public Initiator getMemberEnvironment(String configFile) throws NullPointerException; - public Acceptor getExchangeEnvironment(String configFile) throws NullPointerException; -} \ No newline at end of file + public boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger, InstanceType instanceType) throws FileNotFoundException , NullPointerException; +} diff --git a/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceKafkaAbstractSimple.java b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceKafkaAbstractSimple.java index 14b2722..baf99a5 100644 --- a/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceKafkaAbstractSimple.java +++ b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceKafkaAbstractSimple.java @@ -10,14 +10,22 @@ * Description : *****************************************************************************/ +import java.io.FileNotFoundException; import java.util.List; +import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; + /** * @author John Greenan * @see Kafka * */ public abstract class InterfaceKafkaAbstractSimple { + + public abstract boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger) throws FileNotFoundException , NullPointerException; + + /** * Instantiates a new Abstract class, SimpleKafka. *

diff --git a/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceKafkaProducer.java b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceKafkaProducer.java new file mode 100644 index 0000000..355ceef --- /dev/null +++ b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceKafkaProducer.java @@ -0,0 +1,21 @@ +package com.alignmentsystems.library.interfaces; + +/****************************************************************************** + * + * Author : John Greenan + * Contact : sales@alignment-systems.com + * Date : 20th September 2023 + * Copyright : Alignment Systems Ltd 2023 + * Project : Alignment Matching Toy + * Artefact : InterfaceKafkaProducer + * Description : + *****************************************************************************/ + +import java.io.FileNotFoundException; + +import com.alignmentsystems.library.AlignmentLogEncapsulation; +import com.alignmentsystems.library.AlignmentPersistenceToFileClient; + +public abstract interface InterfaceKafkaProducer { + public abstract boolean initialise(AlignmentLogEncapsulation log, AlignmentPersistenceToFileClient debugger) throws FileNotFoundException , NullPointerException; +} diff --git a/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceOrderSender.java b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceOrderSender.java new file mode 100644 index 0000000..0533b62 --- /dev/null +++ b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfaceOrderSender.java @@ -0,0 +1,18 @@ +package com.alignmentsystems.library.interfaces; + +import com.alignmentsystems.library.AlignmentKafkaSender; + +/****************************************************************************** + * + * Author : John Greenan + * Contact : sales@alignment-systems.com + * Date : 20th September 2023 + * Copyright : Alignment Systems Ltd 2023 + * Project : Alignment Matching Toy + * Artefact : InterfaceOrderSender + * Description : + *****************************************************************************/ + +public interface InterfaceOrderSender { + public void send(AlignmentKafkaSender sender); +} diff --git a/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfacePersistenceClient.java b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfacePersistenceClient.java index ca8f79d..34a71f0 100644 --- a/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfacePersistenceClient.java +++ b/sharedlibrary/src/main/java/com/alignmentsystems/library/interfaces/InterfacePersistenceClient.java @@ -75,7 +75,7 @@ public interface InterfacePersistenceClient { * @param e Exception to log * @return Was this logged? */ - public Boolean error(String toLog, Exception e) throws LogMessageIsNull; + public Boolean error(String toLog, Throwable t) throws LogMessageIsNull; /** * * @param toLog The data to add to the log file @@ -83,7 +83,7 @@ public interface InterfacePersistenceClient { * @param e Exception to log * @return Was this logged? */ - public Boolean errorSession(String toLog, String methodName, Exception e) throws LogMessageIsNull; + public Boolean errorSession(String toLog, String methodName, Throwable t) throws LogMessageIsNull; /** * * @param toLog The data to add to the log file diff --git a/sharedlibrary/version.properties b/sharedlibrary/version.properties index bf6f003..1be8fb0 100644 --- a/sharedlibrary/version.properties +++ b/sharedlibrary/version.properties @@ -1,2 +1,2 @@ -#Tue Sep 19 20:48:23 AEST 2023 -VERSION_BUILD=752 +#Wed Sep 20 19:01:38 AEST 2023 +VERSION_BUILD=779