Spring批处理和集成

发布于 2024-10-03 22:24:32 字数 126 浏览 0 评论 0原文

我是 Spring 的初学者,我必须为学校做一个项目。我可以做什么样的项目,我可以使用 Spring Batch 和 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

暖树树初阳… 2024-10-10 22:24:32

我自己不是 Spring 或 Spring Batch 或 Spring Integration 方面的专家,但我可以告诉您我必须在我的组织中执行的一项实际任务,才能使用所有这些来满足需求。

我的公司在客户注册时收取他们的信用卡,并每 30 天收费一次。因此,每天我们必须查看谁在第 30 天,并通过向他们收费来自动续订我们的服务。因此我必须每天向银行发送数据。

步骤:1 我必须编写一个程序,通过批处理程序从我们的安全数据库中获取当天到期的客户信用卡详细信息,并以银行希望的特定格式将此内容写入临时文件中。作为“.txt”文件在我们公司服务器中的位置(例如:/user/someuser/endofdaytransaction/dd-mm-yyyy.txt)

步骤:2 一旦内容 (dd-mm- yyyy.txt)在此目录中可用(/user/oneworld/endofdaytransaction/) 我必须连接到银行的 SFTP 服务器并将文件传输到银行提供给我们的目录。

我使用 Spring Batch 执行步骤:1,每天下午 5 点通过 Quartz 调度程序触发批处理作业,使用 Spring Integration 执行步骤:2 不断轮询目录,一旦找到文件,就将其传输到银行。

我还从Spring文档中看到我可以将这些技术进行混搭,即我可以避免写入临时目录并要求Spring Integration直接写入银行的SFTP服务器。

我能想到的其他实际例子:我有 AT&T 并订阅了自动付款,即他们每 30 天向我收费一次,并保持我的互联网和电话服务处于活动状态。我已向 AT&T 提供了我的银行信用卡详细信息。它们汇总所有要计费的信用卡(订户),并将数据发送到每天特定时间需要计费的 VISA 或 MASTERCARD 作为批处理文件。我希望您能理解我提到的步骤 1 和步骤 2。快乐学习!

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!

病毒体 2024-10-10 22:24:32

但我无法想象可以结合这些技术的场景

很好地结合这些技术的场景,让我们以一家需要大量批处理作业的相当大的公司为例
通过 Spring 集成,您可以建立一个系统来

  • 管理批处理
  • 作业,根据资源计划作业(例如,在特定时间窗口运行批处理作业,以免破坏在线业务)
  • ,只需启动/停止作业,
  • 提供作业状态视图,

实际上它只是

  • 调度
  • 报告
  • 进行管理

通过 许多企业消息概念
请参阅 http://www.eaipatterns.com/ 已链接到 http://www.springsource.org/spring-integration

适合您的范围 - 学校项目 - 如果您确实有一些工作(3等等),那么你可以构建一个批处理启动工具,一个 GUI(spring mvc),它提供启动/停止/监视/查看这些作业的报告的按钮,但我认为这是一个非常大的项目,可以轻松跨越许多人- 几周

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

何处潇湘 2024-10-10 22:24:32

SpringSource 博主 Dave Syer 有一个集成两者的绝佳示例(没有双关语): Spring Batch 和 Spring 集成的实际使用

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

烙印 2024-10-10 22:24:32

让我们想象一下,您正在为健康维护组织 (HMO) 构建健康系统。这样的系统可能有以下要求:

  1. 对于那些一年多没有接受健康检查的患者,发送电子邮件和/或短信提醒他们需要检查。

  2. 为了鼓励患者进行健康检查,请在电子邮件或短信中允许“回复”功能,通知接待员致电安排预约。

  3. 对于那些需要定期随访的慢性病患者,也可以向他们发送电子邮件或短信。

  4. 每周都缠着病人,直到他们得到该死的检查,但为了理智,不要更频繁。

显然,这样的健康系统将有一个数据库来跟踪患者,该数据库可能有一个如下表:

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)
);

对于短信,这是 JMS 的理想情况。您可以使用 HornetQ、RabbitMQ、ActiveMQ 或许多其他的。

现在,停下来想一想,如果您要直接使用 Java 来执行此操作,则必须编写所有代码。对于我刚才提到的要求,您无需一行 Java 代码即可编写此应用程序。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文