8

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.

0

4 Answers 4

6

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!

1
  • Which library did you use to upload a file to your bank's SFTP server? Jul 2, 2021 at 3:12
4

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

1
3

There is an excellent example of integrating the two (no pun intended) from the SpringSource blogger Dave Syer: PRACTICAL USE OF SPRING BATCH AND SPRING INTEGRATION

1

Let's imagine, for a moment, that you are building a wellness system for a Health Maintenance Organization (HMO). Such a system might have the following requirements:

  1. For those patients that have not received a wellness exam in over a year, send an email and/or text message reminding them that they need a checkup.

  2. To encourage patients to have their wellness exams, allow a "reply to" feature in the email or text message that notifies the receptionist to call to schedule an appointment.

  3. For those patients that have chronic conditions that need regular follow-up visits, email or text them as well.

  4. Pester patients every week until they get their blasted checkup, but for the love of sanity, not more often than that.

Obviously, such a wellness system would have a database to keep track of patients, that might have a table like this:

CREATE TABLE patient
(
    patient_id  INTEGER,
    first_name  VARCHAR2(255) NOT NULL,
    last_name   VARCHAR2(255) NOT NULL,
    last_checkup_date   DATE,
    follow_up_days  INTEGER
    email_address   VARCHAR2(255),
    mobile_nbr      VARCHAR2(255),
    last_notify_date DATE,
    PRIMARY KEY(patient_id)
);

For the text messaging, that is an ideal case for JMS. You could use HornetQ, RabbitMQ, ActiveMQ, or a host of others.

Now, stop for a moment and think of all the code you'd have to write if you were to do this in straight Java. For the requirements that I just mentioned, you could write this application without one line of Java code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.