esanchezros / quickfixj-spring-boot-starter

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

QuickFixJTemplate not found in spring context #97

Closed ggershaw closed 1 year ago

ggershaw commented 1 year ago

Hi,

I am trying to create a client that responds to the logon message with a market data request. For some reason, no matter how I try, the template is not found in the context.

I'm assuming that you allow the client to send messages with the template although I don't see an example of this in your repo. I could have missed it.

My code is here https://github.com/ggershaw/Examples. The branch is feature/rollback. The code that exercises your code is in the child module spring-boot-starter.

I tried to make my yml file closely resemble yours. I'm wondering if the template is a conditional bean and I am missing the config that brings it to life.

Would you mind creating an example of the client publishing a message using the template?

Thanks much

esanchezros commented 1 year ago

Hi @ggershaw

Have a look at this example https://github.com/esanchezros/quickfixj-spring-boot-starter-examples/tree/master/simple-client-and-server, the QuickFixJTemplate is autowired in the RestController

ggershaw commented 1 year ago

I've seen that example, but I believe it's a server example. Do you have any examples where the client publishes a message?

Thanks Geoff

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Eduardo Sanchez-Ros @.> Sent: Tuesday, December 27, 2022 1:26:40 PM To: esanchezros/quickfixj-spring-boot-starter @.> Cc: Raleigh Fix Fan @.>; Mention @.> Subject: Re: [esanchezros/quickfixj-spring-boot-starter] QuickFixJTemplate not found in spring context (Issue #97)

Hi @ggershawhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fggershaw&data=05%7C01%7C%7C28d6d842fd684ddd3ece08dae837e762%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077624054165028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Z3UzMsKU4Mei9ncVA2MqoBcAR29bRAgN%2FIbVEqh1XvU%3D&reserved=0

Have a look at this example https://github.com/esanchezros/quickfixj-spring-boot-starter-examples/tree/master/simple-client-and-serverhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fesanchezros%2Fquickfixj-spring-boot-starter-examples%2Ftree%2Fmaster%2Fsimple-client-and-server&data=05%7C01%7C%7C28d6d842fd684ddd3ece08dae837e762%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077624054165028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=8qL7VDIkusew1Scw2OuZlAiESZlsrcCugHJV4AH13yQ%3D&reserved=0, the QuickFixJTemplate is autowired in the RestController

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fesanchezros%2Fquickfixj-spring-boot-starter%2Fissues%2F97%23issuecomment-1366093079&data=05%7C01%7C%7C28d6d842fd684ddd3ece08dae837e762%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077624054165028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KDNWFrnkOsDyLIqErQfglJ7pRiPTv70olIkWRq%2FPW%2F8%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGD4VGYDQJ24BWLAWLY3BALWPMYGBANCNFSM6AAAAAATKTFSS4&data=05%7C01%7C%7C28d6d842fd684ddd3ece08dae837e762%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077624054165028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=x0bfdjOxfOHwuLLnn2gTUXy2AsYAcd1gFba8d%2F3fC9E%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

esanchezros commented 1 year ago

The example is both a client and server. I see where the problem is, LoginHandler needs to be a @Component or @Service in order for Spring to autowire the dependency

ggershaw commented 1 year ago

Woops. I didn't mean to check that in. Red Herring.

Please see https://github.com/ggershaw/Examples/blob/feature/rollback/spring-boot-starter/src/main/java/org/gershaw/quickfixj/springboot/client/service/MarketDataRequestService.java

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Eduardo Sanchez-Ros @.> Sent: Tuesday, December 27, 2022 1:39:53 PM To: esanchezros/quickfixj-spring-boot-starter @.> Cc: Raleigh Fix Fan @.>; Mention @.> Subject: Re: [esanchezros/quickfixj-spring-boot-starter] QuickFixJTemplate not found in spring context (Issue #97)

The example is both a client and server. I see where the problem is, LoginHandler needs to be a @Component or @Service in order for Spring to autowire the dependency

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fesanchezros%2Fquickfixj-spring-boot-starter%2Fissues%2F97%23issuecomment-1366099473&data=05%7C01%7C%7C7930e81c436749fdbb1508dae839c018%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077631974967704%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XH02aLumcqaaVj6cCj6ZKRGi7rx9DcUk4KgsWbCF5pU%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGD4VG4SWBCDUMYLNMBAPK3WPMZXTANCNFSM6AAAAAATKTFSS4&data=05%7C01%7C%7C7930e81c436749fdbb1508dae839c018%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077631974967704%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=9ZOgs8ezcRX9jNkINCppG2DYZdYV0d12ErqkF%2B%2B1f%2BY%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

esanchezros commented 1 year ago

I tried autowiring the QuickFixJTemplate bean on both client and server examples and it works. I wonder if Spring is trying to match the bean by name rather than type. Could you try renaming the constructor parameter to quickFixJTemplate? I probably should check out the code and try debugging the issue

ggershaw commented 1 year ago

Hi,

I cleaned up the branch and removed the handler package. I tried renaming the constructor arg to no avail.

Normally spring would wire up by type. I tried removing the template from constructor injection and just use the autowired annotation just because I was feeling silly.

I'm going to checkout your code and give it a whirl.

Thanks

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Eduardo Sanchez-Ros @.> Sent: Tuesday, December 27, 2022, 4:42 PM To: esanchezros/quickfixj-spring-boot-starter @.> Cc: Raleigh Fix Fan @.>; Mention @.> Subject: Re: [esanchezros/quickfixj-spring-boot-starter] QuickFixJTemplate not found in spring context (Issue #97)

I tried autowiring the QuickFixJTemplate bean on both client and server examples and it works. I wonder if Spring is trying to match the bean by name rather than type. Could you try renaming the constructor variable to quickFixJTemplate? I probably should check out the code and try debugging the issue

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fesanchezros%2Fquickfixj-spring-boot-starter%2Fissues%2F97%23issuecomment-1366194235&data=05%7C01%7C%7C48f620f76eb741e8151408dae8532fa3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077741235112652%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Ifej%2FUDw3DvIi1YvYVNT8jUlkuTGbZK%2BkyxSk4rJHoE%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGD4VG2QVORR4NJPB2DBRHLWPNPCLANCNFSM6AAAAAATKTFSS4&data=05%7C01%7C%7C48f620f76eb741e8151408dae8532fa3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077741235112652%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=GlK8Kuh7Xf5F%2FE16I%2B8ux3HRLsrCuYm0hQK5gFAgajY%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

ggershaw commented 1 year ago

Hey,

I checked in a failing unit test that just confirms the autowiring is good.

It's called BootifiedClientTest.

Thanks Geoff

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Geoffrey Gershaw @.> Sent: Tuesday, December 27, 2022 8:05:31 PM To: esanchezros/quickfixj-spring-boot-starter @.>; esanchezros/quickfixj-spring-boot-starter @.> Cc: Raleigh Fix Fan @.>; Mention @.***> Subject: Re: [esanchezros/quickfixj-spring-boot-starter] QuickFixJTemplate not found in spring context (Issue #97)

Hi,

I cleaned up the branch and removed the handler package. I tried renaming the constructor arg to no avail.

Normally spring would wire up by type. I tried removing the template from constructor injection and just use the autowired annotation just because I was feeling silly.

I'm going to checkout your code and give it a whirl.

Thanks

Get Outlook for Androidhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2FAAb9ysg&data=05%7C01%7C%7C2211a184122848bf304d08dae86fa061%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077863386849680%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5WgKNQSqjEzi4MkZtp62BulC1CVPF4y7asdyL%2BgNhKs%3D&reserved=0


From: Eduardo Sanchez-Ros @.> Sent: Tuesday, December 27, 2022, 4:42 PM To: esanchezros/quickfixj-spring-boot-starter @.> Cc: Raleigh Fix Fan @.>; Mention @.> Subject: Re: [esanchezros/quickfixj-spring-boot-starter] QuickFixJTemplate not found in spring context (Issue #97)

I tried autowiring the QuickFixJTemplate bean on both client and server examples and it works. I wonder if Spring is trying to match the bean by name rather than type. Could you try renaming the constructor variable to quickFixJTemplate? I probably should check out the code and try debugging the issue

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fesanchezros%2Fquickfixj-spring-boot-starter%2Fissues%2F97%23issuecomment-1366194235&data=05%7C01%7C%7C2211a184122848bf304d08dae86fa061%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077863386849680%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=vwsi%2FmDYnDT9whSU9oy8lZzV0b0MpWgj8yYeoxNg%2F2Y%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGD4VG2QVORR4NJPB2DBRHLWPNPCLANCNFSM6AAAAAATKTFSS4&data=05%7C01%7C%7C2211a184122848bf304d08dae86fa061%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638077863386849680%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mqd%2BMIzRonwjc94W2CRx56Q5RvK0vrFNylCG3atyNtc%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

esanchezros commented 1 year ago

Hi @ggershaw

It seems like the boot starter isn't working properly with Spring 3.0.0. Downgrading to 2.7.6 works as expected.

I have made it work with 3.0.0 by including this in Config:

@Configuration
@ImportAutoConfiguration(classes = {QuickFixJTemplateAutoConfiguration.class, QuickFixJClientAutoConfiguration.class})
public class Config {

}

I'll keep this ticket opened for a while and will create a separate ticket for this bug.

Thanks

ggershaw commented 1 year ago

Great detective work. I was thinking it might be boot 3.0, but I guess i forgot about it. I'm going to finish the example by pumping market data from the server.

I notice that the app runs and then exits successfully. Do you think it would be possible to read from standard out after the springapp starts and keep running till someone hits a key.

Great job man!!

Best, Geoff

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Eduardo Sanchez-Ros @.> Sent: Wednesday, December 28, 2022, 12:52 AM To: esanchezros/quickfixj-spring-boot-starter @.> Cc: Raleigh Fix Fan @.>; Mention @.> Subject: Re: [esanchezros/quickfixj-spring-boot-starter] QuickFixJTemplate not found in spring context (Issue #97)

Hi @ggershawhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fggershaw&data=05%7C01%7C%7C5a76d9d8759248d2462808dae897be97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638078035685022701%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=o6GG6ghouWa5ehxdWqae4ttBZMFq4MdZ5%2BfS8vGyAKc%3D&reserved=0

It seems like the boot starter isn't working properly with Spring 3.0.0. Downgrading to 2.7.6 works as expected.

I have made it work with 3.0.0 by including this in Config:

@Configuration @ImportAutoConfiguration(classes = {QuickFixJTemplateAutoConfiguration.class, QuickFixJClientAutoConfiguration.class}) public class Config {

}

I'll keep this ticket opened for a while and will create a separate ticket for this bug.

Thanks

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fesanchezros%2Fquickfixj-spring-boot-starter%2Fissues%2F97%23issuecomment-1366387924&data=05%7C01%7C%7C5a76d9d8759248d2462808dae897be97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638078035685022701%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DrGGcOVADb51DPj9eNlX0axnQ92XcgPvApH0VSKeftM%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGD4VG5SG2XS3TOVPAVZDX3WPPISXANCNFSM6AAAAAATKTFSS4&data=05%7C01%7C%7C5a76d9d8759248d2462808dae897be97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638078035685022701%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=owd6JAFZeutUJBq1MG8dMJl2QFUkJybUdlZ4YDF0wAA%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

ggershaw commented 1 year ago

Hi,

I force pushed to the branch with the latest code. I have a main class for the client and the server. I started them both up and I would expect to see FIX messages in the console as I set log-factory: screen for both the client and server in the yaml file. Additionally, I have a logback config file setup in the resources dir with root level set to debug.

Unfortunately, I’m not seeing any FIX messages in the console. I also don’t see the log messages I added to confirm that the spring event listener mechanism is working. For instance, have a look at MarketDataRequestService. That log message on line 34, is never printed. I assume, I’m doing something incorrectly or there is something going on with your starter and 3.x version of boot. I will try rolling back to boot 2.x and see if the code starts working.

Thanks,

Geoff

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

From: Eduardo @.> Sent: Wednesday, December 28, 2022 12:52 AM To: @.> Cc: Raleigh Fix @.>; @.> Subject: Re: [esanchezros/quickfixj-spring-boot-starter] QuickFixJTemplate not found in spring context (Issue #97)

Hi @ggershawhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fggershaw&data=05%7C01%7C%7C5a76d9d8759248d2462808dae897be97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638078035685022701%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=o6GG6ghouWa5ehxdWqae4ttBZMFq4MdZ5%2BfS8vGyAKc%3D&reserved=0

It seems like the boot starter isn't working properly with Spring 3.0.0. Downgrading to 2.7.6 works as expected.

I have made it work with 3.0.0 by including this in Config:

@Configuration

@ImportAutoConfiguration(classes = {QuickFixJTemplateAutoConfiguration.class, QuickFixJClientAutoConfiguration.class})

public class Config {

}

I'll keep this ticket opened for a while and will create a separate ticket for this bug.

Thanks

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fesanchezros%2Fquickfixj-spring-boot-starter%2Fissues%2F97%23issuecomment-1366387924&data=05%7C01%7C%7C5a76d9d8759248d2462808dae897be97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638078035685022701%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DrGGcOVADb51DPj9eNlX0axnQ92XcgPvApH0VSKeftM%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGD4VG5SG2XS3TOVPAVZDX3WPPISXANCNFSM6AAAAAATKTFSS4&data=05%7C01%7C%7C5a76d9d8759248d2462808dae897be97%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638078035685022701%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=owd6JAFZeutUJBq1MG8dMJl2QFUkJybUdlZ4YDF0wAA%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

esanchezros commented 1 year ago

If you downgrade to 2.7.6 it should start the initiator and will try connecting to the acceptor. If you want to continue using 3.0.0 then you need to use the workaround as stated before:

@Configuration
@ImportAutoConfiguration(classes = {QuickFixJTemplateAutoConfiguration.class, QuickFixJClientAutoConfiguration.class})
public class Config { }
esanchezros commented 1 year ago

Fixed on 2.15.2