Skip to content

Commit 50f2f3c

Browse files
committed
Added an example of using the artifact build using legacy quickfixj code generator
1 parent 3dc0a0f commit 50f2f3c

File tree

15 files changed

+590
-6
lines changed

15 files changed

+590
-6
lines changed

custom-applications/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<modules>
1717
<module>using-fixlatest-server</module>
1818
<module>using-fixlatest-client</module>
19-
<!-- <module>using-legacy-codegen</module>-->
19+
<module>using-legacy-codegen-server</module>
20+
<module>using-legacy-codegen-client</module>
2021
</modules>
2122
</project>

custom-applications/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Example Applications
22

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

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

custom-applications/using-fixlatest-client/src/main/java/org/quickfixj/examples/fixlatest/custom/client/ClientMessageCracker.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77
import quickfix.fixlatest.BusinessMessageReject;
88
import quickfix.fixlatest.ExecutionReport;
99
import quickfix.fixlatest.MessageCracker;
10-
import quickfix.fixlatest.NewOrderSingle;
1110
import quickfix.fixlatest.component.Instrument;
1211

13-
import java.time.LocalDateTime;
14-
import java.util.UUID;
15-
1612
public class ClientMessageCracker extends MessageCracker {
1713
private final Logger log = LoggerFactory.getLogger(ClientMessageCracker.class);
1814

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<groupId>org.quickfixj.custom.examples</groupId>
6+
<artifactId>custom-applications-parent</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>using-legacy-codegen-client</artifactId>
11+
<packaging>jar</packaging>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>io.allune</groupId>
16+
<artifactId>quickfixj-spring-boot-starter</artifactId>
17+
</dependency>
18+
<dependency>
19+
<groupId>io.allune</groupId>
20+
<artifactId>quickfixj-spring-boot-actuator</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.slf4j</groupId>
28+
<artifactId>slf4j-api</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.slf4j</groupId>
32+
<artifactId>slf4j-simple</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.quickfixj</groupId>
36+
<artifactId>quickfixj-core</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.quickfixj</groupId>
40+
<artifactId>quickfixj-messages-fixt11</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.quickfixj.custom.examples</groupId>
44+
<artifactId>legacy-codegen-application-messages</artifactId>
45+
<version>0.0.1-SNAPSHOT</version>
46+
</dependency>
47+
48+
</dependencies>
49+
50+
<build>
51+
<finalName>${project.artifactId}</finalName>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-maven-plugin</artifactId>
56+
<executions>
57+
<execution>
58+
<goals>
59+
<goal>repackage</goal>
60+
</goals>
61+
</execution>
62+
</executions>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.quickfixj.examples.legacy.custom.client;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class ClientApplication {
8+
public static void main(String[] args) throws InterruptedException {
9+
SpringApplication.run(ClientApplication.class, args);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package org.quickfixj.examples.legacy.custom.client;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import quickfix.*;
6+
import quickfix.field.*;
7+
import quickfix.fix50sp2.MessageCracker;
8+
import quickfix.fix50sp2.NewOrderSingle;
9+
import quickfix.fix50sp2.component.Instrument;
10+
import quickfix.fix50sp2.component.OrderQtyData;
11+
12+
import java.time.LocalDateTime;
13+
import java.util.UUID;
14+
15+
public class ClientApplicationAdapter implements Application {
16+
17+
private final MessageCracker messageCracker;
18+
private final Logger log = LoggerFactory.getLogger(ClientApplicationAdapter.class);
19+
20+
public ClientApplicationAdapter(MessageCracker messageCracker) {
21+
this.messageCracker = messageCracker;
22+
}
23+
24+
@Override
25+
public void onLogon(SessionID sessionID) {
26+
log.info("logged on [{}] - [{}]", sessionID.getSenderCompID(), sessionID.getTargetCompID());
27+
try {
28+
Session.sendToTarget(newOrderSingle(),sessionID);
29+
} catch (SessionNotFound e) {
30+
log.error("SessionNot Found", e);
31+
}
32+
}
33+
34+
@Override
35+
public void onLogout(SessionID sessionID) {
36+
log.info("logged out [{}] - [{}]", sessionID.getSenderCompID(), sessionID.getTargetCompID());
37+
}
38+
39+
@Override
40+
public void fromAdmin(Message message, SessionID sessionId) {
41+
log.info("fromAdmin: Message={}, SessionId={}", message, sessionId);
42+
}
43+
44+
@Override
45+
public void onCreate(SessionID sessionId) {
46+
log.info("onCreate: SessionId={}", sessionId);
47+
}
48+
49+
@Override
50+
public void toAdmin(Message message, SessionID sessionId) {
51+
log.info("toAdmin: Message={}, SessionId={}", message, sessionId);
52+
}
53+
54+
@Override
55+
public void toApp(Message message, SessionID sessionId) {
56+
log.info("toApp: Message={}, SessionId={}", message, sessionId);
57+
}
58+
59+
@Override
60+
public void fromApp(Message message, SessionID sessionID)
61+
throws FieldNotFound, IncorrectTagValue, UnsupportedMessageType {
62+
this.messageCracker.crack(message, sessionID);
63+
}
64+
65+
private static NewOrderSingle newOrderSingle() {
66+
NewOrderSingle newOrderSingle = new NewOrderSingle();
67+
newOrderSingle.set(new ClOrdID(UUID.randomUUID().toString()));
68+
newOrderSingle.set(new OrdType(OrdType.LIMIT));
69+
newOrderSingle.set(new Price(99.09d));
70+
newOrderSingle.set(new Side(Side.BUY));
71+
newOrderSingle.set(new TransactTime(LocalDateTime.now()));
72+
Instrument instrument = new Instrument();
73+
instrument.set(new Symbol("EX.AMPLE"));
74+
instrument.set(new SecurityIDSource(SecurityIDSource.EXAMPLE_CUSTOM_SECURITY_ID_SOURCE));
75+
instrument.set(new SecurityID("202491685"));
76+
newOrderSingle.set(instrument);
77+
OrderQtyData orderQtyData = new OrderQtyData();
78+
orderQtyData.set(new OrderQty(1.0d));
79+
newOrderSingle.set(orderQtyData);
80+
return newOrderSingle;
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.quickfixj.examples.legacy.custom.client;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import quickfix.*;
6+
import quickfix.fix50sp2.MessageCracker;
7+
8+
@Configuration
9+
public class ClientApplicationConfiguration {
10+
11+
@Bean
12+
MessageCracker messageCracker() {
13+
return new ClientMessageCracker();
14+
}
15+
16+
@Bean
17+
Application application(MessageCracker messageCracker) {
18+
return new ClientApplicationAdapter(messageCracker);
19+
}
20+
21+
@Bean
22+
Initiator clientInitiator(
23+
Application clientApplication,
24+
MessageStoreFactory clientMessageStoreFactory,
25+
SessionSettings clientSessionSettings,
26+
LogFactory clientLogFactory,
27+
MessageFactory clientMessageFactory) throws ConfigError {
28+
return new ThreadedSocketInitiator(clientApplication, clientMessageStoreFactory, clientSessionSettings,
29+
clientLogFactory, clientMessageFactory);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.quickfixj.examples.legacy.custom.client;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import quickfix.FieldNotFound;
6+
import quickfix.SessionID;
7+
import quickfix.field.*;
8+
import quickfix.fix50sp2.BusinessMessageReject;
9+
import quickfix.fix50sp2.ExecutionReport;
10+
import quickfix.fix50sp2.MessageCracker;
11+
import quickfix.fix50sp2.component.Instrument;
12+
13+
public class ClientMessageCracker extends MessageCracker {
14+
private final Logger log = LoggerFactory.getLogger(ClientMessageCracker.class);
15+
16+
@Override
17+
public void onMessage(ExecutionReport executionReport, SessionID sessionID)
18+
throws FieldNotFound {
19+
Instrument instrumentComponent = executionReport.getInstrument(); // invariant
20+
log.info("Received ExecutionReport from sender [{}]:: clOrdID {}, symbol {}, side {}, transactTime {}, ordType {}, securityIDSource {}, securityID {}",
21+
executionReport.getHeader().getString(SenderCompID.FIELD),
22+
instrumentComponent.getSymbol().getValue(),
23+
executionReport.getClOrdID().getValue(),
24+
executionReport.getSide().getValue(),
25+
executionReport.getTransactTime().getValue(),
26+
executionReport.getOrdType().getValue(),
27+
instrumentComponent.isSetSecurityIDSource() ? instrumentComponent.getSecurityIDSource().getValue() : "",
28+
instrumentComponent.isSetSecurityID() ? instrumentComponent.getSecurityID().getValue() : "");
29+
}
30+
31+
@Override
32+
public void onMessage(BusinessMessageReject businessMessageReject, SessionID sessionID)
33+
throws FieldNotFound {
34+
log.error("Received Business Message Reject from sender [{}]: refMsgType {}, businessRejectReason{}, Text {}",
35+
sessionID.getSenderCompID(),
36+
businessMessageReject.getRefMsgType().getValue(),
37+
businessMessageReject.getBusinessRejectReason().getValue(),
38+
businessMessageReject.isSetText() ? businessMessageReject.getText().getValue() : "");
39+
}
40+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
spring:
2+
main:
3+
allow-bean-definition-overriding: true
4+
5+
server:
6+
port: 8083
7+
8+
management:
9+
endpoint:
10+
health:
11+
show-details: always
12+
quickfixjclient:
13+
enabled: true
14+
endpoints:
15+
web:
16+
exposure:
17+
include: quickfixjclient,health
18+
19+
app:
20+
session:
21+
sender-comp-id: L-INITIATOR
22+
23+
quickfixj:
24+
client:
25+
enabled: true
26+
configString: |
27+
[default]
28+
BeginString=FIXT.1.1
29+
DefaultApplVerID=FIX.5.0SP2
30+
UseDataDictionary=Y
31+
TransportDataDictionary=FIXT11.xml
32+
AppDataDictionary.FIX.5.0SP2=FIX50SP2.modified.xml
33+
ConnectionType=initiator
34+
TimeZone=Europe/London
35+
StartTime=00:00:00
36+
EndTime=00:00:00
37+
ResetOnLogon=Y
38+
ResetOnLogout=Y
39+
ResetOnDisconnect=Y
40+
ValidateUnorderedFields=Y
41+
ValidateUserDefinedFields=Y
42+
CheckLatency=Y
43+
HeartBtInt=30
44+
PersistMessages=N
45+
SocketConnectHost=localhost
46+
SenderCompID=${app.session.sender-comp-id}
47+
48+
#SSL
49+
SocketUseSSL=N
50+
51+
[session]
52+
TargetCompID=L-ACCEPTOR
53+
SocketConnectPort=9882
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<groupId>org.quickfixj.custom.examples</groupId>
6+
<artifactId>custom-applications-parent</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>using-legacy-codegen-server</artifactId>
11+
<packaging>jar</packaging>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>io.allune</groupId>
16+
<artifactId>quickfixj-spring-boot-starter</artifactId>
17+
</dependency>
18+
<dependency>
19+
<groupId>io.allune</groupId>
20+
<artifactId>quickfixj-spring-boot-actuator</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.slf4j</groupId>
28+
<artifactId>slf4j-api</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.slf4j</groupId>
32+
<artifactId>slf4j-simple</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.quickfixj</groupId>
36+
<artifactId>quickfixj-core</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.quickfixj</groupId>
40+
<artifactId>quickfixj-messages-fixt11</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.quickfixj.custom.examples</groupId>
44+
<artifactId>legacy-codegen-application-messages</artifactId>
45+
<version>0.0.1-SNAPSHOT</version>
46+
</dependency>
47+
48+
</dependencies>
49+
50+
<build>
51+
<finalName>${project.artifactId}</finalName>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-maven-plugin</artifactId>
56+
<executions>
57+
<execution>
58+
<goals>
59+
<goal>repackage</goal>
60+
</goals>
61+
</execution>
62+
</executions>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
</project>

0 commit comments

Comments
 (0)