How to integrate Apache Camel with Jersey 2.x? - spring-boot

I have been trying to integrate apache camel with Jersey 2.x. Basically, i have some rest api implements using Jersey. For some special requirements, i am forced to use camel routes for representing rest endpoints.
I was searching tutorial, but could not find any.
But, I have found such as Apache camel with Spring boot sample->
and spring-boot-sample-jersey.
I was trying to combining those two. But I am not sure whether it is a right approach or not.
I have found Apache Camel could work well with Apache CXF. But my requirement is to integrate Jersey with Apache Camel.
Could you suggest any idea or tutorials for integrating Jersey with Apache Camel?
Notes: I have checked: Camel-Jersey Integration, which did not fulfill my requirements.

There is no first class camel-jersey component.
However you can call Camel from Jersey in the JAX-RS resource class.
There is a little example here, but its using CXF (not camel-cxf) as the example. But you could do similar with Jersey instead of CXF: https://github.com/camelinaction/camelinaction2/tree/master/chapter10/cxf-rest-camel

Related

Spring SOAP Webservice Consumer/Client example using apache HttpClient5

Spring SOAP Webservice Consumer/Client example using apache HttpClient5
Spring SOAP Webservice is still using HttpClient implementation, HttpClient 4.x. When I open the Spring WS API for org.springframework.ws.transport.http.HttpComponentsMessageSender to set ConnectionTimeout, it still uses HttpClient 4.x java classes.
But I am looking for Spring SOAP WebService using apache HttpClient5 component classes.
Can someone help here to provide the equivalent example.
Please dont give me old examples.
I am using Java 17, SpringBoot 3.0.1, Spring-ws-core 4.0.0
I referred internet, here are some of the below URLs
https://hc.apache.org/httpcomponents-client-5.2.x/migration-guide/index.html
https://snehapatil02.medium.com/soap-web-service-client-with-spring-boot-3c7034351c46
How to set timeout in Spring WebServiceTemplate
It is still in the works.
If you really want to use it you can always use the ClientHttpRequestMessageSender, which uses the Spring Framework ClientHttpRequest abstraction, which does support Apache Http Client5.

What is the equivalent object of Exchange (Camel) in Spring Boot?

I am trying to migrate an application built with Camel in Spring Boot, but i'm not using the Exchange object of Camel, so i have to use some other object to do the work of Exchange. Can anybody give me an idea about that?
SpringBoot is not an integration framework like Camel. Spring Integration is the counterpart of Camel in the Spring ecosystem. Although SpringBoot and the Spring framework works very well with Camel too.
However, the Camel Exchange is a Camel concept. I think there is nothing similar in Spring Integration.
The Camel Exchange is like an internal, enriched message. A wrapper around an in- and out-message (out is deprecated since Camel 3) and it holds additional state information such as Exchange properties (non-routable headers), Exceptions etc.
As far as I know, in Spring integration there is just the message. No wrapper around it.

Does Apache Camel replace or complement creating micro-services with Spring Boot?

I have been working for a while with Spring micro-services and have no come across Apache Camel as a tool for building micro-services. I'm unclear -- is Apache Camel a replacement for creating micro-sevices with Spring Boot or does it add functionality / short-cuts to developing such services with Spring Boot? It's already fairly simple to create microservices with Spring Boot so it's hard to imagine what Apache Camel would add but that is the essence of my question.
Apache Camel has nothing to do with microservices.
It's an implementation of the Enterprise Integration Patterns: https://www.enterpriseintegrationpatterns.com/
Apache Camel provides an implementation for most of the patterns from the book from Gregor Hohpe and Bobby Woolf. Plus a variety of inbound and outbound endpoints to integrate with systems like the file system, FTP, HTTP, Messaging, Facebook etc.
Find more information on the website: https://camel.apache.org/
There is a Spring Boot Starter project to run Camel in a Spring Boot application:
https://camel.apache.org/spring-boot.html
what Apache Camel would add, that is the essence of my question
In service of declaring REST based microservices, Camel's REST DSL provides a fluent API for declaring microservices. Take for example:
rest("/books").produces("application/json")
.get().outType(Book[].class)
.to("bean:bookService?method=getBooks(${header.bookCategory})")
Should tell you at a glance that requests to the path /books will get you a List of Book, as long as you send a request parameter named bookCategory. This is mapped to a POJO bean called bookService.
Spring Boot is a framework which simplifies application packing and startup while Spring is the actual framework which has libraries for performing various tasks.
Technically, we can use Camel for building micro-services as well and many aspects of camel depend on Spring. If you foresee many integration related functionality like sending email or communicating with other system, you can use also use Hexagonal architecture.

Soap client framework

I have web application on Spring MVC and looking for SOAP consumer - frameworks to be used with Spring MVC. The web app is only the consumer and doesn't host any web service.
Options I am looking for SOAP client are :
1. JAX-WS
2. Spring MVC & Spring-WS
3. Apache Axis or CXF
4. Spring Integration or Camel. Can these be used for consumption of
services too? Won't that be overhead?
What do you suggest? Please recommend the best option if also not in the above list.
Thanks in advance.
Look at this excellent post about this subject.
Which framework is better CXF or Spring-WS?
My advise based on the fact that you only have to develop one client, is to consider making your choice based on your context to optimize your productivity and avoid adding tones of layer and libs in your app:
Pure Java EE app or already using Spring APP
Your current Application Server : Jboss for example already provide a CXF implementation that is very suggested to use
Service providers "age": I have met some problems in calling AS400 or old IBM system webservices. Any client was not working.
Your IDE and Plugins : for example, if you have eclipse, Axis/CXF plugins are very interesting.
Concerning Camel, it is interesting if you have different source and destination like HTTP to JMS.
For Camel, read this post:
What exactly is Apache Camel?

JAX-RS 2.0 jersey ready for project to be put into production in April-May?

I am building a RESTful web application in which I am interested to use asynchronous functionality and filtering. The application needs to be in production around April/May. Is it a good idea to start working on the available options for JAX-RS 2.0 Jersey since I cannot utilize this functionality in JAX-RS 1.0. If not then I might have to look into other options like Play Framework (which I am currently evaluating). I have seen that Resteasy 2.3.5 also has the required functionality but I was hoping to use the proper JAX-RS 2.0 implementation.
Thank you.
if your app server is jboss 7.x I recomend you RESTEasy, Jboss people is responsible for RESTEasy and it's integrate with JBoss 7.x, the problem with RESTEasy and Jersey is security, please read about OAuth before you choose something, security is important, please implement this first, no only read, implement it

Resources