thanks for attention,i defined a combine spring batch and spring integration project and communicate with ftp server to retrieve file and process on it and write on ftp, i am looking for a good architecture for my project, i designed an architecture with spring integration as bellow diagram:
when retrieve file from server process on it and route files based on condition to mvChannel and toGet channel, i have many process scenario on the retrieved file from server that i defined a router that router handle the scenario , and route to job channels and run spring batch
now, my is question is that are right the architecture?
Really looks good. It is is typical pattern to get gain from both Spring Integration and Spring Batch worlds integration them.
However I don't see reason in the last <aggregator>. All your jobs can send their result to the <int-ftp:outbound-gateway command="PUT">. Looks like no need to wait for all results to do some analysis on them in the single place.
Related
I am using Spring Batch ItemReader to read data from a database and then using FlatFileItemWriter to write the data to a file.
Once the data is written to a file, I need this specific file to be transferred to an FTP server. Can I do this via Spring Batch or should I use Spring Integration? Could you please also provide an example?
There is nothing wrong in combining both frameworks. They really work together smoothly.
Since you say that you already have a Spring Batch ItemReader and your OK writing into a file using FlatFileItemWriter, so you are have way out for your whole solution.
In the end you can use a Providing Feedback with Informational Messages to get a file and send it to FTP using Spring Integration FTP Outbound Channel adapter.
See more info in Spring Batch Docs: https://docs.spring.io/spring-batch/4.2.x/reference/html/spring-batch-integration.html#providing-feedback-with-informational-messages
And in Spring Integration about FTP support: https://docs.spring.io/spring-integration/docs/current/reference/html/#ftp
I am curious to learn, Which design approach you would take in following scenario?
I have a FTP server where my java spring app (Service 1) will go and fetch the file. I will then store that file on to a S3 bucket. this file may have up to a million records. There is going to be another micro service (Service 2) which would need to need read this file data.
How would you design and expose these million records from service1 so that those would readable by Service 2?
Which technology stack you would use on either side and why?
these both services are going to hosted on same servers(For now).
Can you suggest a quick and efficient solution?
Thanks
Here's my approach. I wouldn't even create 2 services provided your scope of work. The only service will use Spring Integration and Spring Batch.
Spring Integration part will get the file from FTP and copy it to S3 and hands over to Spring Batch for processing
After processing with Batch, save the records.
If the job is to run once in a while and don't have much records, I would even not use Spring Batch. I would just use Spring Integration and process the records in parallel. But if you know you'll have millions of records and tons of files, you should consider using Spring Batch for batch processing.
I need to develop an application to perform the following activities using Spring Batch. Read data from the database --> Process data and prepare rest API request --> Write or Post into third party restful service.
I have seen a lot of examples for reading from the database to write to CSV, DB, JMS.
But I don't find any options to write into web service. Is it possible to perform this activity using spring batch or please suggest some other technology.
Spring Batch does not have a RestItemReader since the possibilities are a bit too great as to what we'd need to send. That being said, writing your own ItemWriter implementation that uses a RestTemplate to send the data would be very straight forward to do.
I have requirement something like this:
once the request is received by my service, i need to send it 2-3 third party servers at a time and get the response from all server and return the response.
How can I achieve that?.
My thought : I can create separate threads for different servers and send the request to all servers parallely, but here the issue is, how I will come to know the threads are finished and consolidate the response from all servers and return to caller.
Is there any other way to do in spring boot(micro service)?.
You can leverage asyn feature supported by Spring Framework. Let's see the folllowing example which issue multiple calls in Async style from Spring's official guides:Async Method
Another possible solution for internal communications between Microserives is to use the message queue.
You didn't specify what type of services are you consuming. If they are HTTP, you may want to use some Enterprise Integrations abstractions (most popular are Spring Integration and Apache Camel).
If you don't want to introduce message bus solution into your microservice, you may want to take a look at AsyncRestTemplate
I am new to spring batch. I want to run spring batch jobs on server a and want to launch those jobs from server b using spring batch admin.is it possible? I have searched the following two ways:
1.JMX way: i could convert spring batch beans into mbeans but i cant read them from spring batch admin.can you tell how to read mbeans from spring batch admin and launch them?
2.common repository: i think if i use the same db repository for both spring batch and spring batch admin then i can launch remote jobs from spring batch admin (from server b).but in the job xml file in spring batch admin what should be the classpath for tasklet?
can you help in the above or tell me if any new way exists?
we ended up implementing a framework using mq communication to handle this. each 'batch node' registers itself and any 'batch class' parameters such as 'nodeType=A' or 'jobSizeiCanHandle=BIG' (these are fictitious but you get the point). The client console reads this information and queries the nodes via MQ for the job list. It then submits job requests with parameters via a rudimentary text based protocol (property file format).
command=START_JOB
job=JobABC
param1=x
param2=y
One of the batch nodes will pick up the message and start the job, it will return success/fail status in the same manner with a message with the same correlation id. so the client can show response to the user.
this allows us to do what you're talking about AND spark the jobs via an external scheduler (Control-M) . The 'nodeType=A' mentioned above allows us to query individual nodes (the nodes listen where 'nodeType=A or nodeType=*'. This allows commands to be 'targeted' to specific nodes if that is necessary.
Keep in mind, this is our own console, not the spring batch admin console. So perhaps that doesn't help you, but building up a simple console doesn't take that long using the spring batch APIs (4 or 5 asps).
The batch nodes could also have started up simple services like HTTP REST services or 'whatever' but we use MQ heavily and i liked the idea of not having to preregister nodes (the framework code doesn't know/care that it's in an HTTP container, so it couldn't register the endpoint easily). With MQ, the channel is preconfigured and all apps just 'use it' so it seemed easier.
Good luck.
I am trying to do the same thing. But it seems that in order to launch job directly from Spring batch admin, all the job resource has to be added to the spring batch web app. May be try restful job submission with spring MVC
#chau
One way to use Spring batch admin as is, but "discover" and "invoke" remote jobs is to provide your own implementations for org.springframework.batch.admin.service.JobService and org.springframework.batch.core.launch.JobOperator that can query and invoke jobs from remote job registry/repository.
You can find custom implementation for JobService and JMX enabled Job administrator in : https://github.com/regunathb/Trooper/tree/master/batch-core as: org.trpr.platform.batch.impl.spring.admin.SimpleJobService and org.trpr.platform.batch.impl.spring.jmx.JobAdministrator
Spring beans XML that uses these beans are here : https://github.com/regunathb/Trooper/blob/master/batch-core/src/main/resources/packaged/common-batch-config.xml