Camel prevents graceful Spring Boot actuator shutdown - java

Introducing version 3.20.1 of
camel-spring-boot-starter
camel-core
camel-file-starter
camel-endpointdsl
and
camel.springboot.main-run-controller=true
camel.springboot.use-mdc-logging=true
to the application.properties and a simple file route to a Spring boot 2.7.8 web app using spring-boot-starter-actuator prevents the shutdown actuator from completing a graceful shutdown. Routes are shut down along with other Spring Components, but the VM does not exit as it does without Camel present.
Are there any workarounds for this?

Turns out that
camel.springboot.main-run-controller=true
was what created the problem and it does not seem to be necessary anymore to keep camel running.

Related

Spring Boot : Disable Quartz Scheduler

We are using Quartz Scheduler in our Spring Boot Application.
There is a scenario for which we want to disable it.
We have tried using #ConditionalOnProperty(name = Constant.QUARTZ_ENABLED) option on our class.
We have defined quartz.enabled = false property in application.properties file.
However when we run on Tomcat server locally on Spring Tool Suite it is working as expected (meaning it is not invoking the quartz scheduler).
But when same code is deployed on Weblogic, the scheduler is still running.
Should we try putting #ConditionalOnProperty(name = Constant.QUARTZ_ENABLED) annotation at method level. specifically the method where trigger is used?
We have gone through the options mentioned on various forums but still not reached the solution.
Is there any way we can
1. Stop the scheduler from starting
Or
2. Stop the Job from getting triggered
Thanks in advance.

Is it possible/advisable to run Spring Boot without controllers just for the #ScheduledTasks and ORM?

I'd like to run a Spring Boot service without any of the controller-related stuff. I'd like it to just run a scheduled task every hour and do work if needed. I'm wanting to use Spring Boot, because I already know how to set the Hibernate ORM up, and I'm re-using a lot of the same repositories as another Spring Boot service. So, I spun up a new Spring Boot project and left out the start-web package.
The main issue I'm running into is that despite having a scheduled task set up, the service starts and immediately quits without running the scheduled task. In my head, I imagined the service kind of just sitting there, running, waiting for the time to trigger the scheduled job I have configured and kind of just sleeping until then. Are my expectations bad, or do I just have it misconfigured?
I've solved the problem. It was a configuration issue causing the Spring Boot app to not recognize the presence of required configuration values in the application.properties file.
You can either remove spring-boot-starter-web from your dependencies or in your main class you can configure the SpringApplicationBuilder to not include the web server.
new SpringApplicationBuilder(YourApplication.class)
.web(WebApplicationType.NONE)
.run(args);
Use #EnableScheduling in main class and application won't shuts down.

Time Out Exception for all requests in Spring Boot application

I want to stop the services after 30Sec.
Here I'm using SpringBoot application and it has many Rest API's. Default time out is 60Sec in tomcat.
Set this property in application.properties
server.tomcat.connection-timeout=30s
You can find all configuration properties of Spring Boot in the documentation: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#common-application-properties

Start ignite with spring boot in service on request

Spring boot requires to create a bean instance. Due to which the pods are started as I run the application
#Bean
Ignite ignite(IgniteConfiguration igniteConfiguration) {
Ignition.start(igniteConfiguration)
}
Is there any way that I can configure and start it in spring boot service on receiving a request?
You can add #Lazy annotation for bean declaration and also combine #Lazy with #Autowired annotation in your service.
More information here:
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/Lazy.html
This is not recommended, because Ignite startup may be a lengthy process, and you probably don't want to wait for it upon getting a request (only to learn that startup failed, for example) and certainly not start it per request.
Also, consider using IgniteSpringBean instead of raw Ignite.

How to know Spring Boot starting errors in details in console

I know that this is a very trivial question but please suggest me to find the way. Sometimes when I start Spring Boot server, it stops but it does not display the complete error/exception stack trace. Think of situation that spring boot server has been started in 8080 port and if somebody starts in 8080 port, it should clearly display that java.net.BindException. But in my case server simply aborts.
I normally find the issue from the IDE like eclipse/Idea when I start the server in debug mode. But how to find the error when somebody starts spring boot server using command prompt ? There may be many errors for which spring boot is unable to start. My question is what configurations should be added in application.properties to know more details about the error/s for which spring boot is not getting started. Currently I am using Spring Boot 2.1.1.RELEASE version. Please help me fix this.
To see more details of the actions being carried out for a spring boot application, change the log level to debug. You can do it just by simply adding below lines in application.property/yaml file.
logging.level.=DEBUG
Or for web applications you can try
logging.level.org.springframework.web: DEBUG
Add the below property in application.xml - worked in Spring boot 2.2.4
logging.level.root:ERROR

Categories