Apache Kafka + Spring Cloud Task

Recently I was working on a piece of the project which required to perform a batch job, run application 1 time and once it successfully completed – terminate it. Spring Cloud Task fits perfect for this kind of requirement. Our usual stack of technologies is Spring Cloud Stream/Task and Apache Kafka. In my earlier posts, I showed you an example how to use Spring Cloud Stream + Apache Kafka. However, I never used Spring Cloud Task, so I start browsing for examples and… I found nothing. There is no example of Spring Cloud Task with Apache Kafka. At least I couldn’t find. So I dig into that and come up with a solution.
Continue reading “Apache Kafka + Spring Cloud Task”

Spring Cloud Stream + Apache Kafka(PollableMessageSource)

Hi there! Recently Spring Cloud Stream 2.0 introduced a new feature – polled consumers(PollableMessageSource), where the application can control the reading rate from a source (Kafka, RabbitMQ), basically you can pause your stream. It is especially helpful in the case of Kafka. Before the new feature, you will just read continuously payload from the topic as much as it has, non-stop. What if you need to pause your stream? Say we are getting messages from Kafka topic and then we are sending data to some external service and at some point, external service becomes unavailable.
For this use case, I created an application, that deals with such an issue.
Continue reading “Spring Cloud Stream + Apache Kafka(PollableMessageSource)”

Spring’s WebClient testing + findings from Async/RestTemplate.

Several weeks ago I was working on a task where I have to do millions of REST HTTP calls from java app to external service. First I tried to use Spring’s RestTemplate, but it was too slow for my case because it’s synchronous(lets say server response rate 30ms and I have to make 2M requests, which leads us to approx 16 hours, in single thread mode). Then I started looking for something asynchronous and luckily Spring has AsyncRestTemplate. It has similar functionality as RestTemplate, but only difference is that it returns ListenableFuture.
Continue reading “Spring’s WebClient testing + findings from Async/RestTemplate.”