Data aggregation with Spring Data MongoDB and Spring Boot

1 Introduction MongoDB aggregation framework is designed for grouping documents and transforming them into an aggregated result. The aggregation query consists in defining several stages that will be executed in a pipeline. If you are interested in more in-depth details about the framework, then mongodb…

Spring Integration – Configure web service client timeout

1 Introduction With the support of Spring Integration, your application can invoke a web service by using an outbound web service gateway. The invocation is handled by this gateway. Hence, you just need to worry about building the request message and handling the response. However,…

Migrating Spring MVC RESTful web services to Spring 4

1 Introduction Spring 4 brings several improvements¬†for MVC applications. In this post I will focus on restful web services and try these improvements by performing a migration from Spring MVC 3.2 to Spring 4.0. We will take a project implemented with Spring 3.2 and perform…

How error handling works in Spring Integration

1 Introduction The target of this post is to show you how error handling works in Spring Integration, using the messaging system. You will see that error handling is different between synchronous and asynchronous messaging. As usual, I’ll skip the chat and proceed with some…

Processing messages in transactions with Spring JMS

1 Introduction This post shows how to process messages in transactions with Spring JMS. We will see how an error in the execution of the consumer during the asynchronous reception of messages with JMS, can lead to the loss of messages. I then will explain…

Introduction to messaging with Spring JMS

1 Introduction to Spring JMS In this post I will show you how to configure a standalone application in order to see different ways of sending and receiving messages using Spring JMS. Basically, I will divide the examples into the following sections: Point-to-point messaging (queue)…

Unit testing with PowerMock

In this article I will implement unit testing with PowerMock library. This framework is more powerful than other libraries and allows you to mock static methods, private methods and change field properties among other things. I will use the Mockito extension but it also supports…

Centralize validation and exception handling with @ControllerAdvice

1 Introduction The ControllerAdvice annotation introduced by Spring 3.2 allows us to handle several functionalities in a way that can be shared by all controllers (through its handler methods, annotated with @RequestMapping). This annotation is mainly used to define the following methods: @ExceptionHandler: Handles exceptions…