0

First time using Spring boot.

I am trying to create a service with two methods. First one to consume json messages & append them to a file. The other to read the file & return list of messages.

To reduce overhead, I would like to open the file when the web app starts & close the file when the app terminates.

Any pointers would be appreciated.

Thanks

  • is there any specific reason for using the file? why don't you use some kind of database? – deadshot Jul 30 '22 at 13:24
  • "_I would like to open the file when the web app starts_" - Does the following answer this piece of your question? [Running code after Spring Boot starts](https://stackoverflow.com/q/27405713/12567365) – andrewJames Jul 30 '22 at 13:55
  • "_& close the file when the app terminates_" - And for this piece? [Spring Boot shutdown hook](https://stackoverflow.com/q/26678208/12567365) – andrewJames Jul 30 '22 at 13:56
  • `To reduce overhead, ...` you won't notice the difference if you open (,read, write) and close the file on each request. But you should synchronize, because it is a shared resource among requests at the same time. – PeterMmm Jul 30 '22 at 16:54
  • Thanks @deadshot - I am trying to do a PoC for an existing application (COBOL app on x86) which writes to flat files. I would like to understand how this would behave running this across 2 servers in a GFS2/Pacemaker cluster. – user2809072 Jul 30 '22 at 22:06
  • Hey @andrewJames - The app I am trying to PoC creates some files on startup & keeps them open until the process shuts down or a new file needs to be created. – user2809072 Jul 30 '22 at 22:07
  • Hi @PeterMmm - Thanks, will look into it. That’s where it gets a bit tricky. – user2809072 Jul 30 '22 at 22:07
  • Yes, that is my understanding of your question. – andrewJames Jul 30 '22 at 22:27

0 Answers0