Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring batch and Integration

I am a beginner to Spring and I have to do a project for school. What kind of project can I do which I can use Spring Batch and Integration. I know that I can write files into directories, write, read and modify comma separated files but I can`t picture a scenario which I can combine these technologies.

like image 893
nobo Avatar asked Nov 22 '10 12:11

nobo


2 Answers

I am no expert myself on Spring or Spring Batch or Spring Integration, but I can tell you a practical task that I had to do in my organization to use all of these for a requirement.

My company takes the credit card from our clients when they sign up and charge them every 30 days. So everyday we have to see who are on the 30th day and autorenew our service to them by charging them. Hence I have to send the data to the banks on a daily basis.

Step: 1 I had to write a program to fetch credit card details of customers due on that day from our secured database through a batch program and write this content in a particular format that the bank desires into a temporary location in our company's server as a ".txt" file (Ex: /user/someuser/endofdaytransaction/dd-mm-yyyy.txt)

Step: 2 As soon as the content (dd-mm-yyyy.txt) is available in this directory (/user/oneworld/endofdaytransaction/) I have to connect to the bank's SFTP server and transfer the file to the directory the bank has provided us.

I use Spring Batch for Step: 1, the batch job is triggered through a Quartz scheduler everyday at 5pm and Spring Integration for Step: 2 to keep polling the directory and once the file is found transfer it to the bank.

I also see from the Spring documents that I can do a mashup of these technologies, i.e., I can avoid writing to a temporary directory and ask Spring Integration to directly write to the SFTP server of the bank.

Other practical example I could think of: I have AT&T and have subscribed to Auto-pay, i.e they bill me every 30 days and keep my internet and phone service active. I have provided AT&T my bank credit card details. They aggregate all the credit cards (subscribers) to be billed and send the data to VISA or MASTERCARD who needs to be billed as a batch file every day at a specific time. I hope you can relate to the Step 1 and Step 2 I have mentioned. Happy learning!

like image 116
oneworld Avatar answered Oct 06 '22 00:10

oneworld


but I can`t picture a scenario which I can combine these technologies

well lets take a rather large company which needs a lot of batchjobs with spring integration you could set up a system to

  • manage the batchjobs
  • plan the jobs according to resources (e.g. run batchjobs in certain time windows to not break online business)
  • simply start/stop the jobs
  • provide job status views

actually its just

  • scheduling
  • reporting
  • managing

through many enterprise message concepts see http://www.eaipatterns.com/ its already linked at http://www.springsource.org/spring-integration

for your scope - the school project - and if you have really some jobs (3 and more), well you could build a batch start tool, a GUI (spring mvc) which provides buttons to start/stop/monitor/see reports for those jobs, but i think thats a really large project, which could easily span many man-weeks

like image 35
Michael Pralow Avatar answered Oct 06 '22 00:10

Michael Pralow