Rate limit API in spring boot - spring-boot

I am building an application based on spring boot. A requirement to protect the application is the API access rate limit.
I have read a lot of articles on this issue. However, it has not yet found a way to get started.
I have found bucket4j, redis, ratelimiter guava. Give me an opinion on the solution that you find it reasonable.
Thanks !

Related

How to set limit in consuming message from google Pub/Sub?

I just want to consume 1000 messages per minute from google pub/sup in my spring boot application. Is there a way to set it like this in spring boot application? I searched many websites but didn't find anything helpful.

How to get spring boot cloud/actuator to support prometheus Exemplars?

The Exemplars support essentially adds the trace-id to metrics that are being scraped. I found a tutorial on how would it work with GoLang[1] but cannot figure out how to do this with spring boot libraries/functionalities. I know that Prometheus Java Client supports it as described at [2] but not sure how to get it to work with Springboot.
https://vbehar.medium.com/using-prometheus-exemplars-to-jump-from-metrics-to-traces-in-grafana-249e721d4192
https://github.com/prometheus/client_java/pull/615
Update: Exemplars are supported by Micrometer and Spring Cloud Sleuth.
I'm not 100% sure I get your question right: I'm assuming you are talking about the /actuator/prometheus endpoint.
The support for metrics in Spring is provided by Micrometer that also supports Prometheus and Spring Boot "just" sets up an actuator endpoint for it.
So the real question is: does Micrometer support exemplars? Right now it does not and we haven't had anyone asking for it so far (this issue is a little bit connected). So if you want this feature, please open an issue(Enhancement request) on GitHub.
Update: I opened an issue for this: https://github.com/micrometer-metrics/micrometer/issues/2672, please feel free to +1 or chime-in.
Adding exemplars support in Micrometer is not the end of the story, we need to add support for Spring Cloud Sleuth too and solve a few other potential issues.
Until this is implemented, I guess your best bet is using the prometheus client.

Web API Notification using Spring Boot

I am looking at creating Notification in Google Chrome, using Spring Boot. The notification is nowadays common on all sites.
The Spring Boot Admin module does create the same notification if the client application monitored goes down or comes up.
Can some help me with the same, very less support on the internet for the same? Even if the concept is clarified I can share a sample code for Spring boot and make it public via git. Else if a working sample help will also be appreciated.
We have JS way of creating the same, using new Notification('Title',) and window.webkitNotifications.createNotification.
I have solved it using 2 parts.
Server-Sent-Events (sse) emitters with Spring boot and Notification Web APIs
Adding the sample code here
Hope it helps someone looking for a similar solution.

why we use jersey with spring? What are the benefits?

I want to know that why we use jersey with spring and what are the benefits of using it.
I have searched on google but not getting proper answer so i am asking this question here.Sorry because i know my question is old but i am very confused now.
Please suggest me the example of jersey with spring and hibernate.
Thanx in advance.
I use Jersey2 with Spring in one of my projects and in the other Spring MVC4. The advantage of Jersey is its simplicity. If you are creating only RESTful Web services - use Jersey, if you have to generate also some web pages for users, consider to use Spring MVC.
Additionally, I develop my applications on Google Cloud, so the warm up time is very important (if there is a traffic spike, many instances have to wake up in the background to be ready for incoming requests) - according to my tests Jersey is a bit faster than MVC.
Here you have an example of complete configuration:
Integrating Jersey 2 and Spring with Java Based Configuration

Spring XD REST Service

I would like to have a REST service to expose the data read and processed from Spring XD. Similar to the one in the Analytics Server.
For example I would like my own functions which can be exposed similar to Counters and be able to access the data from a web browser.
Is there any tutorial? I have searched and found that Spring Boot is the one but I am looking for help on how I integrate it with Spring XD.
Would be very helpful if someone can point me to the instructions on how I can achieve this.
You can use trigger as a source with http-client as a processor processor to access any web browsers info regardless if it is a web service URL or not.
Moha.

Resources