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

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.

Related

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.

Is Spring Boot just for Microservices ? can i use Spring Boot for Monolithic architecture?

Is Spring Boot just for Microservices or can I use Spring Boot for Monolithic architecture?
Spring Boot in itself has nothing to do with microservices. It's a Spring module which simply makes the configuration of your app easier. As such, it absolutely can be used in a monolithic app.
From the official docs:
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".
We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.
Features
Create stand-alone Spring applications
Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
Provide opinionated 'starter' dependencies to simplify your build configuration
Automatically configure Spring and 3rd party libraries whenever possible
Provide production-ready features such as metrics, health checks and externalized configuration
Absolutely no code generation and no requirement for XML configuration

Spring Cloud Netflix - how to access Eureka/Ribbon from traditional web app?

Everything I found on the internet about Spring Cloud Netflix is about running microservices from Boot applications using #EnableEurekaClients and so on.
Now I'm trying to connect my logging microservice within a traditional war application (springmvc, jaxws etc) - piece of legacy which can not be converted to Boot or modified in any way (by technical task).
I've created a new maven module "log-server-client" that knows nothing about upper web layer and intended to be used as a simple dependency in any maven project.
How should I configure access to Spring Cloud Netflix for this simple dependency? At least, how to configure Eureka and Ribbon?
I just extracted some lines of code from RestTemplate and created my custom JmsTemplate (microservice works with jms remoting with apache camel and activemq), exactly how it is done in RestTemplate, but this code stil lacks connection to infrastructure
afaik, we can create a global singleton bean, run a separate thread from this bean, and run Boot app from this thread, but don't you think that it is very ugly and can lead to problems? How it really should be used?
Great question!
One approach is to use a "sidecar". This seems to be a companion Spring Boot application that registers with the Eureka Server on behalf of your traditional web app.
See e.g.:
http://www.java-allandsundry.com/2015/09/spring-cloud-sidecar.html
http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_polyglot_support_with_sidecar
Another approach is to use the following library:
"A small lib to allow registration of legacy applications in Eureka service discovery."
https://github.com/sawano/eureka-legacy-registrar
This library can be used outside of Spring Boot.

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

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?

Resources