Skip to content

Commit

Permalink
Added an example of using the artifact build using legacy quickfixj c…
Browse files Browse the repository at this point in the history
…ode generator
  • Loading branch information
david-gibbs committed Oct 21, 2024
1 parent 3dc0a0f commit 50f2f3c
Show file tree
Hide file tree
Showing 15 changed files with 590 additions and 6 deletions.
3 changes: 2 additions & 1 deletion custom-applications/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<modules>
<module>using-fixlatest-server</module>
<module>using-fixlatest-client</module>
<!-- <module>using-legacy-codegen</module>-->
<module>using-legacy-codegen-server</module>
<module>using-legacy-codegen-client</module>
</modules>
</project>
2 changes: 1 addition & 1 deletion custom-applications/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example Applications

The Example applications are trivial and only intended to demonstrate the build and runtime dependencies when using custom protocols.
The example applications are trivial and only intended to demonstrate the build and runtime dependencies when using custom protocols.

The example applications use `quickfixj-spring-boot-starter`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import quickfix.fixlatest.BusinessMessageReject;
import quickfix.fixlatest.ExecutionReport;
import quickfix.fixlatest.MessageCracker;
import quickfix.fixlatest.NewOrderSingle;
import quickfix.fixlatest.component.Instrument;

import java.time.LocalDateTime;
import java.util.UUID;

public class ClientMessageCracker extends MessageCracker {
private final Logger log = LoggerFactory.getLogger(ClientMessageCracker.class);

Expand Down
66 changes: 66 additions & 0 deletions custom-applications/using-legacy-codegen-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.quickfixj.custom.examples</groupId>
<artifactId>custom-applications-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>using-legacy-codegen-client</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>io.allune</groupId>
<artifactId>quickfixj-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.allune</groupId>
<artifactId>quickfixj-spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.quickfixj</groupId>
<artifactId>quickfixj-core</artifactId>
</dependency>
<dependency>
<groupId>org.quickfixj</groupId>
<artifactId>quickfixj-messages-fixt11</artifactId>
</dependency>
<dependency>
<groupId>org.quickfixj.custom.examples</groupId>
<artifactId>legacy-codegen-application-messages</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.quickfixj.examples.legacy.custom.client;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ClientApplication {
public static void main(String[] args) throws InterruptedException {
SpringApplication.run(ClientApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.quickfixj.examples.legacy.custom.client;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import quickfix.*;
import quickfix.field.*;
import quickfix.fix50sp2.MessageCracker;
import quickfix.fix50sp2.NewOrderSingle;
import quickfix.fix50sp2.component.Instrument;
import quickfix.fix50sp2.component.OrderQtyData;

import java.time.LocalDateTime;
import java.util.UUID;

public class ClientApplicationAdapter implements Application {

private final MessageCracker messageCracker;
private final Logger log = LoggerFactory.getLogger(ClientApplicationAdapter.class);

public ClientApplicationAdapter(MessageCracker messageCracker) {
this.messageCracker = messageCracker;
}

@Override
public void onLogon(SessionID sessionID) {
log.info("logged on [{}] - [{}]", sessionID.getSenderCompID(), sessionID.getTargetCompID());
try {
Session.sendToTarget(newOrderSingle(),sessionID);
} catch (SessionNotFound e) {
log.error("SessionNot Found", e);
}
}

@Override
public void onLogout(SessionID sessionID) {
log.info("logged out [{}] - [{}]", sessionID.getSenderCompID(), sessionID.getTargetCompID());
}

@Override
public void fromAdmin(Message message, SessionID sessionId) {
log.info("fromAdmin: Message={}, SessionId={}", message, sessionId);
}

@Override
public void onCreate(SessionID sessionId) {
log.info("onCreate: SessionId={}", sessionId);
}

@Override
public void toAdmin(Message message, SessionID sessionId) {
log.info("toAdmin: Message={}, SessionId={}", message, sessionId);
}

@Override
public void toApp(Message message, SessionID sessionId) {
log.info("toApp: Message={}, SessionId={}", message, sessionId);
}

@Override
public void fromApp(Message message, SessionID sessionID)
throws FieldNotFound, IncorrectTagValue, UnsupportedMessageType {
this.messageCracker.crack(message, sessionID);
}

private static NewOrderSingle newOrderSingle() {
NewOrderSingle newOrderSingle = new NewOrderSingle();
newOrderSingle.set(new ClOrdID(UUID.randomUUID().toString()));
newOrderSingle.set(new OrdType(OrdType.LIMIT));
newOrderSingle.set(new Price(99.09d));
newOrderSingle.set(new Side(Side.BUY));
newOrderSingle.set(new TransactTime(LocalDateTime.now()));
Instrument instrument = new Instrument();
instrument.set(new Symbol("EX.AMPLE"));
instrument.set(new SecurityIDSource(SecurityIDSource.EXAMPLE_CUSTOM_SECURITY_ID_SOURCE));
instrument.set(new SecurityID("202491685"));
newOrderSingle.set(instrument);
OrderQtyData orderQtyData = new OrderQtyData();
orderQtyData.set(new OrderQty(1.0d));
newOrderSingle.set(orderQtyData);
return newOrderSingle;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.quickfixj.examples.legacy.custom.client;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import quickfix.*;
import quickfix.fix50sp2.MessageCracker;

@Configuration
public class ClientApplicationConfiguration {

@Bean
MessageCracker messageCracker() {
return new ClientMessageCracker();
}

@Bean
Application application(MessageCracker messageCracker) {
return new ClientApplicationAdapter(messageCracker);
}

@Bean
Initiator clientInitiator(
Application clientApplication,
MessageStoreFactory clientMessageStoreFactory,
SessionSettings clientSessionSettings,
LogFactory clientLogFactory,
MessageFactory clientMessageFactory) throws ConfigError {
return new ThreadedSocketInitiator(clientApplication, clientMessageStoreFactory, clientSessionSettings,
clientLogFactory, clientMessageFactory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.quickfixj.examples.legacy.custom.client;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import quickfix.FieldNotFound;
import quickfix.SessionID;
import quickfix.field.*;
import quickfix.fix50sp2.BusinessMessageReject;
import quickfix.fix50sp2.ExecutionReport;
import quickfix.fix50sp2.MessageCracker;
import quickfix.fix50sp2.component.Instrument;

public class ClientMessageCracker extends MessageCracker {
private final Logger log = LoggerFactory.getLogger(ClientMessageCracker.class);

@Override
public void onMessage(ExecutionReport executionReport, SessionID sessionID)
throws FieldNotFound {
Instrument instrumentComponent = executionReport.getInstrument(); // invariant
log.info("Received ExecutionReport from sender [{}]:: clOrdID {}, symbol {}, side {}, transactTime {}, ordType {}, securityIDSource {}, securityID {}",
executionReport.getHeader().getString(SenderCompID.FIELD),
instrumentComponent.getSymbol().getValue(),
executionReport.getClOrdID().getValue(),
executionReport.getSide().getValue(),
executionReport.getTransactTime().getValue(),
executionReport.getOrdType().getValue(),
instrumentComponent.isSetSecurityIDSource() ? instrumentComponent.getSecurityIDSource().getValue() : "",
instrumentComponent.isSetSecurityID() ? instrumentComponent.getSecurityID().getValue() : "");
}

@Override
public void onMessage(BusinessMessageReject businessMessageReject, SessionID sessionID)
throws FieldNotFound {
log.error("Received Business Message Reject from sender [{}]: refMsgType {}, businessRejectReason{}, Text {}",
sessionID.getSenderCompID(),
businessMessageReject.getRefMsgType().getValue(),
businessMessageReject.getBusinessRejectReason().getValue(),
businessMessageReject.isSetText() ? businessMessageReject.getText().getValue() : "");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
spring:
main:
allow-bean-definition-overriding: true

server:
port: 8083

management:
endpoint:
health:
show-details: always
quickfixjclient:
enabled: true
endpoints:
web:
exposure:
include: quickfixjclient,health

app:
session:
sender-comp-id: L-INITIATOR

quickfixj:
client:
enabled: true
configString: |
[default]
BeginString=FIXT.1.1
DefaultApplVerID=FIX.5.0SP2
UseDataDictionary=Y
TransportDataDictionary=FIXT11.xml
AppDataDictionary.FIX.5.0SP2=FIX50SP2.modified.xml
ConnectionType=initiator
TimeZone=Europe/London
StartTime=00:00:00
EndTime=00:00:00
ResetOnLogon=Y
ResetOnLogout=Y
ResetOnDisconnect=Y
ValidateUnorderedFields=Y
ValidateUserDefinedFields=Y
CheckLatency=Y
HeartBtInt=30
PersistMessages=N
SocketConnectHost=localhost
SenderCompID=${app.session.sender-comp-id}
#SSL
SocketUseSSL=N
[session]
TargetCompID=L-ACCEPTOR
SocketConnectPort=9882
66 changes: 66 additions & 0 deletions custom-applications/using-legacy-codegen-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.quickfixj.custom.examples</groupId>
<artifactId>custom-applications-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>using-legacy-codegen-server</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>io.allune</groupId>
<artifactId>quickfixj-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.allune</groupId>
<artifactId>quickfixj-spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.quickfixj</groupId>
<artifactId>quickfixj-core</artifactId>
</dependency>
<dependency>
<groupId>org.quickfixj</groupId>
<artifactId>quickfixj-messages-fixt11</artifactId>
</dependency>
<dependency>
<groupId>org.quickfixj.custom.examples</groupId>
<artifactId>legacy-codegen-application-messages</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 50f2f3c

Please sign in to comment.