Spring Boot Server Sometimes Just Doesn't Respond to Requests - spring

I am building an API with Spring Boot and Kotlin and I am having a weird experience.
Whenever I am calling any of my built endpoints sometimes the server would never send back a response even though it is still up and running. It is not shutdown, there is no error it would just not send back any response.
What could be the issue?

Related

Spring Boot application in Kotlin starts to answer 404 after some time

I'm having this problem with a new Spring Boot service, written in Kotlin, where I start to get 404 for any REST requests after some random time (When I deploy the service, instead, everything works fine, with the same REST APIs).
In addition, I've also other services, written in Java, that are running without any problem.
Just to specify:
all the components are well defined in the application;
I've moved logging filters and some authorization logic in libraries also used in the java services (services that are running perfectly);
I am not able to reproduce locally, it happens after some time only in staging and prod envs.
Then I've noticed a really strange thing:
when running a public request (so that I skip all the auth logic checks) the logger prints the response status as 200 -> but then the final answer that the client gets is 404.
Do you have any idea or tip?
Thanks
Problem fixed! It was a mistake in the middleware, there were two service without the correct routing setup -> traefik was not able to redirect the traffic in the right way

Spring actuator endpoint seems to be called twice

This does not block me in any way, just curious. Today during debugging my application I run into a weird logs:
{"#timestamp":"2020-04-17T16:30:55.128+0000","#version":"1","message":"Mapped to Actuator web endpoint 'health'","logger_name":"org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping","thread_name":"qtp250197932-43","level":"DEBUG","level_value":10000,"caller_class_name":"org.springframework.web.servlet.handler.AbstractHandlerMapping","caller_method_name":"getHandler","caller_file_name":"AbstractHandlerMapping.java","caller_line_number":414}
{"#timestamp":"2020-04-17T16:30:55.128+0000","#version":"1","message":"Mapped to Actuator web endpoint 'health'","logger_name":"org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping","thread_name":"qtp250197932-45","level":"DEBUG","level_value":10000,"caller_class_name":"org.springframework.web.servlet.handler.AbstractHandlerMapping","caller_method_name":"getHandler","caller_file_name":"AbstractHandlerMapping.java","caller_line_number":414}
Does anyone have an idea why I got two identical records about accessing health endpoint but from different threads?

How can I log every request that is coming to my Webflux application without breaking my reactive capabilities?

Log every request that is coming to my application .Which is the best place to put the filter so that it is not blocking for my application.

Consuming CometD messages with spring webflux

We have a system which publishes messages via cometD.
I wrote a simple java program to establish a connection to the server
then use the bearer token returned from the login to and consume messages
But I want to move this to a Webflux project, but unsure where to start, I can see there is out of box JMS-webflux wrapper, can I use this or is it best to build something similar ?
I'm very new to cometD and have only used simple webflux components,
I can also just use Spring boot, but ideally just like a JmsReceiver or similar
Thanks

custom HTTP status code with spring and restful webservice

I am new to the spring and restful framework. My server hosts 3 restful web services. I have used spring support for the restful web services to implement the server. The client sends JSON request to the server and gets JSON response. Client is based on spring support for the restful. The server returns 200/OK for successful processing, which is default.
What I want is the server to send custom HTTP status code 550 to the client in case there is an issue while processing the request. It should not throw any exception to the client. It should only send 550/an_error_object(as json) back to the client.
How is it possible with the spring support of restful ? I am doing the following on the server side.
HttpServletResponse.setStatus(550)
but, the client side is failing to recognize the status code 550; it throws an exception since org.springframework.http.HttpStatus doesn't have any enum constant '550' defined.
Any suggestions will be great!
Thanks in advance.
Rohit
1) Don't use unregistered status codes. See the registered status codes.
2) That being said, that's a bug in the Spring framework. It should deal properly with extension status codes.
It'll probably going to be fixed in version 4.3 of Spring.
https://jira.spring.io/browse/SPR-14205

Resources