esanchezros / quickfixj-spring-boot-starter

Spring Boot Starter for QuickFIX/J
Apache License 2.0
125 stars 57 forks source link

Problem with postgresql driver #85

Closed jgarciasm closed 2 years ago

jgarciasm commented 2 years ago

I tried to create a project based on quickfixj-spring-boot-starter-examples (simple-client-with-database) but with postgresql. I am using JDK 17. I'm pretty sure it's my mistake and I've tried to fix it in many ways but I can't find the problem. Please help me if it is my mistake.

The problem is this:

When I tried to start my application it fails and show nest message:


***************************
APPLICATION FAILED TO START
***************************

Description:

A configuration error has been detected in the QuickFIX/J settings provided: org.logicalcobwebs.proxool.ProxoolDataSource

Action:

Please configure your QuickFIX/J settings as per the documentation: https://www.quickfixj.org/usermanual/2.1.0/usage/configuration.html

Process finished with exit code 1

That happens when the applications tries to load the MessageStoreFactory and/or LogFactory.

I think is a problem with overlapping org.logicalcobwebs.proxool dependency but I don´t know.

This is my quickfixj.cfg file:

[default]
ConnectionType=initiator
SenderCompID=BANZAI
TargetCompID=FIXIMULATOR
SocketConnectHost=localhost
StartTime=00:00:00
EndTime=00:00:00
HeartBtInt=15
ReconnectInterval=5
UseDataDictionary=N
DataDictionary=FIX42.xml

PersistMessages=Y

JdbcDriver=org.postgresql.Driver
JdbcURL=jdbc:postgresql://localhost/data_fix_client
JdbcUser=postgres
JdbcPassword=postgres
JdbcLogHeartBeats=Y
JdbcStoreMessagesTableName=messages
JdbcStoreSessionsTableName=sessions
JdbcLogEventTable=event_log
JdbcLogIncomingTable=messages_log
JdbcLogOutgoingTable=messages_log
JdbcSessionIdDefaultPropertyValue=not_null

[session]
BeginString=FIX.4.2
SocketConnectPort=9878

And my pom.xml:

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-dbcp2</artifactId>
    </dependency>

    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
    </dependency>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.allune</groupId>
      <artifactId>quickfixj-spring-boot-starter</artifactId>
      <version>2.11.0</version>
    </dependency>

    <dependency>
      <groupId>io.allune</groupId>
      <artifactId>quickfixj-spring-boot-actuator</artifactId>
      <version>2.11.0</version>
    </dependency>

    <!-- https://mavenlibs.com/maven/dependency/proxool/proxool -->
    <dependency>
      <groupId>proxool</groupId>
      <artifactId>proxool</artifactId>
      <version>0.8.3</version>
    </dependency>
esanchezros commented 2 years ago

Hi Jonad, Thanks for reporting the issue. Proxool is very old and has no maintainers but it's the default data source shipped with quickfixj.  For the time being I have pushed a fix for the problem, basically setting the DataSource bean in the jdbc factories:

public MessageStoreFactory clientMessageStoreFactory(SessionSettings clientSessionSettings, DataSource dataSource) {
    JdbcStoreFactory jdbcStoreFactory = new JdbcStoreFactory(clientSessionSettings);
    jdbcStoreFactory.setDataSource(dataSource);
    return jdbcStoreFactory;
}
public LogFactory clientLogFactory(SessionSettings clientSessionSettings, DataSource dataSource) {
    JdbcLogFactory jdbcLogFactory = new JdbcLogFactory(clientSessionSettings);
    jdbcLogFactory.setDataSource(dataSource);
    return jdbcLogFactory;
}

Let me know if that works for you. Thanks

jgarciasm commented 2 years ago

Thank you a lot @esanchezros!!!

Now it works like a charm.