use exceptionMapper for restcontroller so that jersey and restcontroller can coexist - spring-boot

I was using spring boot with Jersey 1. Used ExceptionMapper to handle the exceptions globally. Now we are planning to migrate to spring MVC for restful purpose. So, changing few of the endpoints to use dispatcher servlet.
Is there any way to handle all exceptions using exceptionMapper. There exists ControllerAdvice to handle exceptions globally for spring mvc but is there anyway I can use ExceptionMapper providers for time being?
Thank you

Related

How to make Spring Data REST endpoints asynchronous?

Does anyone know how to make Spring Data REST endpoints asynchronous?
I saw that we can add the annotation #Async with CompletableFuture<?> as returned object on the service methods.
But doing this, makes the use of the interface RepositoryRestResource pointless as we need to implement both the service and controller layers manually...
Or am I missing something here?
Currently Spring Data REST supports blocking I/O only. See this Jira Issue of Spring Data REST support for Spring WebFlux.
Spring MVC has an integration with Servlet 3.0 async request processing.
Although Spring MVC has async support, for non-blocking I/O, Spring WebFlux is recommended, because Spring WebFlux is async by design. See Spring Web MVC Async Request Compared to WebFlux

Spring Rest Controller vs Camel rest servlet in micro services --- What's the difference , is camel have any other adv?

In my previous application, i have exposed rest api using spring rest controllers.
Now i'm going to work in spring boot microservice where they have used , camel rest services.
Is there any adv of camel rest compared with spring rest?
Apache Camel offers a REST styled DSL which can be used with Java or
XML. The intention is to allow end users to define REST services using
a REST style with verbs such as get, post, delete etc.
Source https://camel.apache.org/manual/latest/rest-dsl.html
The idea of Camel REST endpoints is to start e Camel Route with a REST Call.
If you don't need Camel Routes it doesn't make sense to use Camel REST.
On the other side Spring MVC provides the ability to define REST APIs that will use other Spring Components to fullfil use case.

Control migration of a spring jersey app to webflux through a feature flag

We are thinking of how to migrate spring jersey app to webflux gradually, by converting jersey services to webflux controllers, and converting jersey filters to webfilters one by one, controlled by a feature flag. Since webflux can run on modern servlet containers, I am thinking of mapping the original path to a servlet that just does the forwarding based on the value of the feature flag. However, as I understand, spring boot does not allow webflux to co-exist with spring MVC/Jersey. What's a best way to migrate existing app to webflux?

Spring mvc and webflux in 1 spring boot application

I got below instruction from spring boot doc:
Adding both spring-boot-starter-web and spring-boot-starter-webflux modules in your application results in Spring Boot auto-configuring Spring MVC, not WebFlux. This behavior has been chosen because many Spring developers add spring-boot-starter-webflux to their Spring MVC application to use the reactive WebClient. You can still enforce your choice by setting the chosen application type to SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)
My question is:
What if my application contains both MVC services and webflux services?
Is it supported?
For example:
I may have some existing admin service which is MVC based. Now I want to add some new services with webflux style.
No, this is not supported. Spring MVC and Spring WebFlux have different runtime models and don't support the same servers (for example, Spring WebFlux can be run with Netty, Spring MVC cannot).
Also, Spring MVC and Spring WebFlux are full web frameworks, meaning each has its own infrastructure that somehow duplicates the other. Deploying both in the same app would make it difficult to map requests (which requests should go where?).

Spring boot, is it safe to use Spring MVC and Jersey together

Is it safe, or even possible, to use Jersey and Spring MVC together via Spring boot starters? I realize Jersey registers it's own servlet (mapped to /* with default configuration) to handle requests, where as Spring MVC registers it's dispatcher servlet (mapped to / with default configuration).
Is it possible and safe to configure Jersey servlet to handle request under the /api path, where as Spring MVC would still handle all other requests, or would this lead to conflicts/instability, or considered as a bad design solution?

Resources