How to integrate Spring application with Mule ESB - spring

I want to integrate my spring (3.0) application with Mule ESB (Mule3) and make available those service for different clients (.Net, GWT etc). For accomplish this, whether I should deploy my Spring application as separate component and define Endpoint on Mule or I can deploy my spring application inside the Mule and provide those services to outside clients. If anyone know some ideas or any sample reference projects related to this problem, can please update me. Thanks.

I would recommend integrating Mule into your Spring application. That is, adding the Mule jar files to your app and using it as a library. Doing it this way Mule adds a child context to your main Spring application context and has access to your beans so they can be used as services.
The Using Mule with Spring and Spring Application Contexts pages are the places to start learning about how to do this.

Related

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

Consume a service jar by spring boot

I am working on the web service project by Spring Boot, services exist in a jar,
My question is how to consume these services?
Any help is very appreciated.
(according to your tags, you've developed REST services.)
Postman is a great tool (great GUI with many functionalities) to test your REST services.
It's available as Chrome Extension or as stand alone app.

Can you use (any) Spring's functionality outside of Spring (Boot)?

I have just built a RESTful web service with Spring Boot.
I now want to utilise the RESTful web service and start making calls to it by building a java console application (eventually adding GUI and security).
I was wondering if I can use any of the Spring functionality outside of the Spring (Boot) environment and use it in my java console application? For example, can I use Spring's RestTemplate in my non-Spring java application to make the REST api calls? I am new to Spring and I want to stick as close to Spring as possible. I think you can't, but I just want to make sure.
If not possible, I know you can create non-web application with Spring. Is it possible to integrate a GUI? Might not be best practice, just exploring what is possible and conventional.
Spring Boot is not coupled, in any way, to an application type. You can run command-line only apps, batch apps, web apps or any other kind of apps with it. You can even benefit from Spring Boot's auto-configuration.
In the case of the RestTemplate you may want to import spring-web directly rather than spring-boot-starter-web. Or you could add the starter and exclude the embedded container (spring-boot-starter-tomcat). Spring Boot will auto-adapt and not start an embedded web server in that case.

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.

Is anyone focusing on Mule with Spring Boot?

I have been using Spring Boot for a short while and it's great for getting things up and running quickly.
Is anyone working on a template for integrating Mule ESB with Spring Boot ?
Not sure if Mule will be charge of this or not. But you can suggest this in the spring-boot project in github
An approach could be use queues , so mule expose a functionality as queue enpoint and spring boot send and receive string messages to mule queue. I have seen it work in complex scenarios.
Latency will increase but the core of integrations will remain in mule esb.
Other approaches:
Starting mule programmatically from spring boot: http://glawson6.github.io/spring/mule/2015/04/22/using-spring-boot-with-mule.html (not tested)
https://github.com/denschu/mule-spring-boot-starter(not tested)
HTH

Resources