What is the best way to design file handling using spring - spring

I want to make an application is which file handling is used. That is file downloading (get the file), file parsing(process the file) and file uploading. It is not a web project. Actually the idea is we make this project and then make a jar of it and then use it in our further projects. How can i design my application so it is extendable easily in future. Is there is any spring framework for this task?
Thanks

I would suggest either Spring Batch or Apache Camel. These two frameworks can automate the downloading/uploading functionality you are after and let you define the file parsing in a well structured manner. If you are after csv or line-by-line parsing it's already done for you and you'll be at the file parsing bit just with a few configuration. Take a look at the Spring Batch sample examples and Apache Camel examples as a starting point.

Related

How can I set isolation-level-for-create via yaml configuration file for spring batch

I found a solution to do it via Java code here:
https://docs.spring.io/spring-batch/docs/4.2.x/reference/html/job.html#configuringJobRepository
But, I want to do it if possible in a simple way via configuration in yaml format in the batch configuration file.
Thank you.
As far as I know, there is currently no such property in yaml available.
There is an open feature request in Spring Boot (https://github.com/spring-projects/spring-boot/issues/28802) that may result in a property like spring.batch.jdbc.isolation-level-for-create in the future. Until then, you'll need to use Java (or XML) configuration.

Spring Batch and Spring MVC - Best design approach

We have a web application written on SpringMVC. Also, we have some need of running code through batch application (Spring scheduler). Code re-usability view, we thought to have batch code as well part of the application and then generated JAR out of which.
Is it best way to do so having batch and application code part of the same application. Or do we need separate batch application?
Please advise the best design approach here.
Is both are part of same business? As you have to run Spring Batch in background to do some process, it would be better to keep it separate from Spring MVC Application. Each application should be part of one type of business.
First find out how much dependencies are there for making it separate.

Spring batch or Spring core libraries for building file operation process

I'm dipping my toes into the microservices, is spring boot batch applicable to the following requirements?
Files of one or multiple are read from a specific directory in Linux.
Several operations like regex, build new files, write the file and ftp to a location
Send email during a process fail
Using spring boot is confirmed, now the question is
Should I use spring batch or just core spring framework?
I need to integrate with Control-M to trigger the job. Can the Control-M be completely removed by using Spring batch library? As we don't know when to expect the files in the directory.
I've not seen a POC with these requirements. Would someone provide an example POC or an affirmation this could be achieved with Spring batch?
I would use Spring Batch for that use case. Not only does it provide out of the box components for reading, processing, and writing files, it adds a lot more for error handling, scalability, etc. All of those things you'd probably end up wiring up by yourself if you go without Spring Batch.
As for being launched via Control-M, yes MANY large customers use Control-M to launch their jobs. Unfortunately, I've never done it myself so I cannot provide any details on the mechanics, but if Control-M can either launch a script or call a REST API, you can launch a job with it.
I would suggest you, go for spring batch as it has much-inbuilt functionality which will be provided to you for file reading and writing to your required location. Even you will be able to handle record skipping requirement. Your mail triggering requirement will be handled by Control M. You just need to decide one exit code for your handled exception and on the basis of that exit code you can trigger the mail to respective members. And there are many other features which will be helpful if you go for spring batch.

GWAN as embeded server for spring boot

not sure if this is possible but was wondering if its possible to embed GWAN in spring boot app (like tomcat/jetty etc.) are. and how so?
As far as the Spring Boot documentation tells, the requirements are to package your G-WAN application as a jar (zip) file, and install and configure Spring plugins to connect the dots.
One of them, Gradle, takes 50.5 MB to let you use several programming languages: "Gradle makes the impossible possible, the possible easy and the easy elegant."
G-WAN delivers even more language mix in 200 KB of code. G-WAN works without configuration files, nor it needs any war archives to be built, and deployed each time you edit the code of a Java G-WAN script. G-WAN's philosophy is real-time "edit & play".
With some adjustments, it will be possible to use G-WAN with in a Spring Boot application, but thats' like trying to attach a lorry trailer to a formula one: are the expected gains worth the exercise?
If you see advantages at adding this much code, configuration and maintenance overhead to G-WAN, could you please try to enumerate them?
If you are an advanced Spring developer and you still believe that there's value in this proposition, we will help you by adapting G-WAN wherever needed, providing you or other Spring experts can tell what must be done.

Best way to get Spring Bean info from context WIHOUT creating app context?

I have a Spring (3.1.) app that has a large app-context.xml file. There is a second very small stand-alone application that needs just a few parameters from one of the beans that are configured in that xml file.
Rather than that little application instantiating the whole application context (which builds a lot of connections, etc), I just want to read in the couple of configuration parameters that are contained in that file.
I could of course create a new smaller small-app-context.xml that only has the configuration i need or put those parameters in a properties file, but then I need to maintain that information in two places, which I am trying to avoid. I know I could read in and parse the raw XML file (not exactly sure the most efficient way to do that). However, I was hoping that Spring provides a nice way to do this but I haven't found it.
Does Spring provide a clean way to do this?
Thanks.
In Spring you can have multiple configuration files. So for the part that you would like to reuse you would create a smaller, self-contained config file. It can remain in the original project and your app-context.xml can include it. Then your new, small project could include the small config xml and you wouldn't need to maintain the information in two locations.
I could of course create a new smaller small-app-context.xml that only has the configuration i need or put those parameters in a properties file
I would agree that configuration belongs in a properties file. Not the application context file. You should not be maintaining the configuration in two places. You should have the configuration once in your properties file and then make that available to any contexts which require it.

Resources