Let's take a look at a tutorial that explains how to build an application that connects to multiple MongoDBs. Also look at creating the data model and repositories.
Want to find out how to gracefully shutdown your Spring Boot apps? Click here to learn more about shutting down Spring Boot apps and installing newer versions.
This guide walks through the process of creating a central configuration management for microservices using Spring Cloud Config integrating with HashiCorp Vault.
I'm not sure if I completely understand what you're asking, but I'll do my best to answer.
If you are talking about actual HTTP Session that won't work, this strategy mentioned in this article is purely for stateless applications where you do not need to manage sessions but instead manage the dispatch of a request to the downstream services. The state is stored in the token.
The idea is to deploy it not only in different machines but in different regions in the cloud. The article only shows it all deployed in the same machine to make it easier.
It's not entirely true, what the shutdown endpoint does is basically to close the application context, if you use the same example as the one given in this article you will end up with the following response:
curl -i localhost:8080/long-process
curl: (52) Empty reply from server
It just kills the context instead of keep processing the current requests.
Fair point. I'll try to work on the Optional#isPresent example and modify it.
Apart from that, I don't believe I'll touch anything otherwise it would just kill the purpose of this article, that simply shows the options to inject an optional dependency using Spring Framework.
Thanks for your comment Robert, let's walk through it.
1. I do agree with your point and Optional shouldn't be used as a parameter, however, if you are using Constructor Injection that's one way to go to make it optional, otherwise you need to use field injection and mark with required=false.
2. It's just an example about the injection, not really about how to use the Java Optional.
3. I do agree with you on that, but again, I'm showing the available option using Spring, if you are writing a Spring Boot Auto Config and you have an optional parameter, then maybe, you can rely on the DI framework.
Comments
Mar 21, 2020 · Marcos Barbero
It depends on your use-case, as I'm not familiar with your application I can't recommend anything. I'm sorry.
Mar 21, 2020 · Marcos Barbero
I'm not sure if I completely understand what you're asking, but I'll do my best to answer.
If you are talking about actual HTTP Session that won't work, this strategy mentioned in this article is purely for stateless applications where you do not need to manage sessions but instead manage the dispatch of a request to the downstream services. The state is stored in the token.
Mar 18, 2020 · Marcos Barbero
The idea is to deploy it not only in different machines but in different regions in the cloud. The article only shows it all deployed in the same machine to make it easier.
Feb 15, 2019 · Lindsay Burk
That's indeed a good idea, thanks for the heads up!
Feb 15, 2019 · Lauren Forbes
Thanks for the heads up! You are correct, with your input the code will be simplier.
Nov 21, 2018 · Marcos Barbero
Hi Kishan, sorry for the long delay, I was working abroad and missed your message.
Are you using spring-boot? It seems you have some missing dependency or auto configuration in your project.
Jul 03, 2018 · Lindsay Burk
Hello Giuseppe, indeed it's quite useful and it would be nice to be present there.
However, it's not easy to make it an out of the box implementation.
If you follow my original blog post, you can find more information about it in the Footnote section.
Jul 02, 2018 · Lindsay Burk
Hello Piotr, thanks for the comment.
It's not entirely true, what the shutdown endpoint does is basically to close the application context, if you use the same example as the one given in this article you will end up with the following response:
curl -i localhost:8080/long-process
curl: (52) Empty reply from server
It just kills the context instead of keep processing the current requests.
Jun 26, 2018 · Marcos Barbero
Fair point. I'll try to work on the Optional#isPresent example and modify it.
Apart from that, I don't believe I'll touch anything otherwise it would just kill the purpose of this article, that simply shows the options to inject an optional dependency using Spring Framework.
Jun 26, 2018 · Marcos Barbero
Thanks for your comment Robert, let's walk through it.
1. I do agree with your point and Optional shouldn't be used as a parameter, however, if you are using Constructor Injection that's one way to go to make it optional, otherwise you need to use field injection and mark with required=false.
2. It's just an example about the injection, not really about how to use the Java Optional.
3. I do agree with you on that, but again, I'm showing the available option using Spring, if you are writing a Spring Boot Auto Config and you have an optional parameter, then maybe, you can rely on the DI framework.
Mar 14, 2018 · Marcos Barbero
Thanks Rosa Bella, I really appreciate all the support.
If there's something else you wish to read don't hesitate to tell me.