Spring Boot to Spring XD conversion - spring-boot

I have an existing stand-alone Spring Boot (CommandLineRunner) application that generates JSON payloads, currently written to the local file system. Though I could tail that file easily in Spring XD, I'd rather have the entire Spring Boot application run as either a source or job module in Spring XD, but I'm having some difficulties making the conversion. Does anyone know of a Spring XD sample where the XD module (source or job) is the creator/originator of outgoing messages, instead of using some sort of inbound adapter from another external system? (Maybe my entire premise is misguided, but I want the application to be managed by Spring XD so that I don't have to manage another out-of-band orchestration tool to start and stop the JSON-generating process.)

Related

Is it possible to deploy Spring application in SCDF 2.10?

If I have Spring batch jobs bundled within a Spring (Spring version 5.3)application (not a Springboot), Would I still be able to deploy in SCDF-2.10 server, by registering each of these jobs as tasks ? Will this work? Would I be able to register these Spring apps as 'App' in Data flow server? And could I still be able to use Data flow Shell , to register them?
Have already tested Springboot applications on SCDF server by registering as Tasks, but did not find any info on Spring Applications
The SCDF ecosystem was designed around Spring Boot applications. However there is support for polyglot applications.
If the application is packaged in a container and registered as a task, the container will be launched.
If you want it to be visible as a Task then it should include Spring Cloud Task 2.4.x with properties to access the SCDF datasource. These will be provided in the same format as expected by a Spring Boot application.

How to check the java application (non spring boot) if it is up or down

I have this requirement that I need to check if the java application (not web app) is running or down via bash script.
It is non springboot application as well. It is just a normal spring application that connects and listen to kafka, get the the object from the topic and call an API.
We thought of to use spring actuator to check the health however it is not a web application.
What is the recommended way to check a non-web and non-springboot application if it is up or down?
Please advise.

need advice on approach of reading file from the Linux system

I am somewhat new to java and spring.
We have the requirement of reading the file of some thousand records and calling micro service developed in spring boot deployed on PCF.
I have two approaches in my mind. One is we have simple spring boot application where it reads the file and call required micro service. The other is to develop spring batch with dummy item writer which calls micro service.
Confused which one to choose. Any advise here will be appreciated.

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.

Resources