Java spring boot as a windows service alternative - java

I have multiple spring boot projects that a running on windows server. For now I am deploying each project as a windows service because we cant use docker.
Now I was thinking about to reduce the amount of windows services that I have but not change the microservice architecure.
One alternative is OSGi which seems to be very nice but as I have seen it is not recommend to use spring boot apps with OSGi.
The next alternative I was thinking about was to create my own java "controller app" that then can start/stop the other microservices. So only the "controller app" has to be deployed as a windows service.
Is there a better alternative instead of creating a own "controller app"? Docker would be nice but unfortunately we canĀ“t use it. Or should we maybe try to run our spring boot services with OSGi?

Related

Spring Boot scheduled application updates

I want to automate instalation/update process for my app. It's web application in spring boot. Users run this application on their own servers which usually isn't accessible from my build servers.
Requirements
installation is simple
update can be scheduled and is done automatically
fewest dependencies possible
runs on both windows server and linux
reliability & security
Current prototype
Our current prototype is based on docker. There are actually 6 docker images (our app is 2 dockers, watchtower, monitoring agent, zuul + eureka, certbot).
Installation:
download and install docker
download & run a script (it's very thin wrapper around docker compose)
Upgrade:
user checks release notes and schedules an upgrade
app sends to our build server request for new version
image for new version is built & published to repository
watchtower automatically downloads & updates it
This prototype works but it's not very reliable and it feels like overengineering.
Do you have experience with something similar? I will be very happy for opinions how to make it simpler.
Thank you
Have you looked into Spring Batch? It's got a scheduling API that you can run within the spring boot application.

Extending Spring Cloud - Cloud Platform Extensibility

After reading the following post I have a few questions:
https://spring.io/blog/2014/08/05/extending-spring-cloud
Imagine that I have implemented my own Spring Cloud (Cloud Platform Extensibility), and after testing in my local machine I want to deploy in different environments.
Assume that:
My environments have a Docker installation.
I do not want to install the Cloud Foundry architecture in them.
My questions are:
What are the requirements for the different environment to work with my own Spring Cloud? i.e. must I install Spring Cloud Foundry architecture in all the environment machines?
Is Spring Cloud Foundry archictecture compulsory though I have implemented my custom Spring Cloud?
Must I use commands like "cf" to upload and deploy the services?
Many thanks.
Regards,
Paco.
That is an old blog post and I feel it doesn't accurately describe Spring Cloud as it stands today. It refers to the since renamed Spring Cloud Connectors project.
Spring Cloud, built on top of Spring Boot, provides developers an easy way of building "cloud native" and "12 factor" applications. That essentially boils down to the common patterns found in modern applications such as centralized configuration, service discovery, circuit breakers, etc. This is cloud agnostic and works well in a variety of environments including AWS and GCP.
So no, Spring Cloud isn't really directly related to Cloud Foundry, however it works nicely there as it does many other places.
You probably solved your problem, but in case not and for the sake of others i'll post an answer. You can deploy a spring cloud application on docker swarm using docker compose v3 . As shown in this repository , the command docker stack deploy -f all-in-one.yml springcloud deploys the resource specified in all-in-one.yml on docker swarm. You can take a look at how docker stack works in this documentation.

Spring Boot on Android?

Is it possible to run Spring Boot on an Android device?
Right now I am successfully running a web service on localhost using Spring Boot which I've got building in IntelliJ IDEA. I need to get the same web service code running on an Android device. Is it possible to build the web service app into a JAR file that I can get running on an Android phone? I have a Google Nexus 6P running Android Nougat. I've done some limited research, and have found an application called JBED. So far I haven't been able to get this working.
I've started from scratch and built the example JAR:
gs-spring-boot-0.1.0.jar
and hopefully I can find a way to run this JAR. I'm guessing it probably won't work so if anyone has a better idea that would be great!
You can use i-jetty to host servlet based apps in android. or embed i-jetty (replacing tomcat or netty) in your spring boot app
Short answer is you're not gonna be able to directly run your spring boot application on your android phone. Spring boot is meant as a wrapper to quickly bootstrap Spring applications and is going to best serve you when building web based applications. As I see it you have two options.
Deploy your jar on the cloud somewhere(ec2,digitalocean, heroku, cloud foundry, etc.) and just access your Spring MVC app from the android browser. If you have some really complex logic in your boot app that you don't think you can port to android, you can still deploy your boot app in the cloud, and create a really "dumb" front end android application that consumes all of it's data from the spring boot app running externally.
Port you current spring boot application to a true Spring for Android project. http://projects.spring.io/spring-android/. The tools are out there to help you port it over all you have to do is put the work in.
There's an AnLinux app in play store that helps install a Linux distro inside termux.
I was able to install open jdk, spring cli and then run an spring boot project in that.
Here's a video I recorded demoing the same - https://m.youtube.com/watch?v=n9CY2wZPWJ0&t=1s

Bluemix: Java Rest API starter app

I want to run and deploy a java rest API code on Bluemix. This is more to understand the Devops capabilities in conjunction with API management.
I tried to use this: http://www.codingpedia.org/ama/tutorial-rest-api-design-and-implementation-in-java-with-jersey-and-spring/
But could not push it to Bluemix. May I get some support?
Update:
When I push it to Bluemix, I get an error saying it could not find appropriate runtime.
Reading your comments you are searching for some pointers to create a starter Java REST application (possibly integrating a delivery pipeline).
You can start creating an application on Bluemix using the Liberty for Java runtime. Then you can, from your application dashboard, click on "Add Git" to create a Git repository on IBM Bluemix DevOps Services (IDS). Now you have your starter application running on Bluemix and its code hosted on IDS. You can edit the code directly on the Web IDE of IDS (clicking on "Edit Code") and from there push the new versions of the applcation on Bluemix or you can clone the repository on your local environment (for example using the Eclipse Tools for Bluemix) and deploy directly from your machine to Bluemix.
Using the first option you will be able to quickly setup a delivery pipeline using the "Build & Deploy" button, and use the DevOps capabilities of IDS. The Build & Deploy feature, also known as the pipeline, automates the continuous deployment of your projects. In a project's pipeline, sequences of stages retrieve input and run jobs, such as builds, tests, and deployments.
To add REST capabilities to the sample application you can for example use JAX-RS 2.0. Take a look here.
Javaee jax-rs REST API starter
Use my java REST API starter for bluemix. This uses javaee + jax-rs + swagger
Just fork it, run pom.xml to generate war and push the war file to bluemix. Works like a charm
https://github.com/sanketsw/jax_rs_REST_Example
Spring boot REST API starter for bluemix
if you want a spring boot REST API starter, you can use the following boilerplate. This is a netflix eureka client but you can ignore eureka annotations. The REST API will work seamlessly anyway
https://github.com/sanketsw/Netflix_Eureka_Client_Hello_World
Another cleaner springboot REST API starter is here: https://github.com/sanketsw/SpringBoot_REST_API

Which Java Spring components needed for Spring-WS?

I have Eclipse Kepler installed and working properly on Mac OSX. I'd like to install Spring in order to design, write, deploy a RESTful web service.
I see a plethora of components listed on the update site, and little guidance on what I do/don't need in order to just get started.
Do I need :
SpringSource DM Server Tools?
Spring IDE Core Developer Resources?
Web Flow?
If you have Eclipse installed then just follow the tutorial: Building a RESTful Web Service
http://spring.io/guides/gs/rest-service/
It provides details of the Maven/Gradle configuration that you need which will ensure that the correct dependencies are imported.
Note that it makes use of Spring Boot, which in turn will import dependencies required by Spring MVC. You don't need Spring-WS for REST web services. Spring-WS is for building SOAP web services.

Categories

Resources